mirror of
https://github.com/anatolykopyl/vue-three-d-mockup.git
synced 2026-03-26 12:55:08 +00:00
3019 lines
532 KiB
JavaScript
3019 lines
532 KiB
JavaScript
import{_ as sc,r as oc,e as ac,o as lc,c as cc}from"../app.06d4fed4.js";/**
|
|
* @license
|
|
* Copyright 2010-2022 Three.js Authors
|
|
* SPDX-License-Identifier: MIT
|
|
*/const Js="137",hc=0,_o=1,uc=2,il=1,dc=2,Ai=3,Di=0,it=1,si=2,rl=1,ln=0,Li=1,vo=2,yo=3,Mo=4,fc=5,Zn=100,pc=101,mc=102,bo=103,wo=104,gc=200,xc=201,_c=202,vc=203,sl=204,ol=205,yc=206,Mc=207,bc=208,wc=209,Sc=210,Ec=0,Tc=1,Ac=2,Fs=3,Cc=4,Lc=5,Rc=6,Pc=7,Nr=0,Dc=1,Ic=2,cn=0,Fc=1,Nc=2,Bc=3,zc=4,Uc=5,al=300,Vi=301,Gi=302,Ns=303,Bs=304,Br=306,Zs=307,zs=1e3,St=1001,Us=1002,rt=1003,So=1004,Eo=1005,ut=1006,Oc=1007,zr=1008,hn=1009,Hc=1010,Vc=1011,Ii=1012,Gc=1013,Ar=1014,Sn=1015,ti=1016,kc=1017,Wc=1018,ni=1020,qc=1021,Xc=1022,xt=1023,jc=1024,Yc=1025,Tn=1026,oi=1027,Jc=1028,Zc=1029,$c=1030,Kc=1031,Qc=1033,jr=33776,Yr=33777,Jr=33778,Zr=33779,To=35840,Ao=35841,Co=35842,Lo=35843,eh=36196,Ro=37492,Po=37496,Do=37808,Io=37809,Fo=37810,No=37811,Bo=37812,zo=37813,Uo=37814,Oo=37815,Ho=37816,Vo=37817,Go=37818,ko=37819,Wo=37820,qo=37821,Xo=36492,th=2200,nh=2201,ih=2202,Lr=2300,Rr=2301,$r=2302,$n=2400,Kn=2401,Pr=2402,$s=2500,ll=2501,rh=0,mn=3e3,je=3001,sh=3200,oh=3201,ci=0,ah=1,Kr=7680,lh=519,Fi=35044,Dr=35048,jo="300 es",Os=1035;class Cn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e);e.target=null}}}const ht=[];for(let s=0;s<256;s++)ht[s]=(s<16?"0":"")+s.toString(16);const Qr=Math.PI/180,Hs=180/Math.PI;function Ht(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ht[s&255]+ht[s>>8&255]+ht[s>>16&255]+ht[s>>24&255]+"-"+ht[e&255]+ht[e>>8&255]+"-"+ht[e>>16&15|64]+ht[e>>24&255]+"-"+ht[t&63|128]+ht[t>>8&255]+"-"+ht[t>>16&255]+ht[t>>24&255]+ht[n&255]+ht[n>>8&255]+ht[n>>16&255]+ht[n>>24&255]).toUpperCase()}function wt(s,e,t){return Math.max(e,Math.min(t,s))}function ch(s,e){return(s%e+e)%e}function es(s,e,t){return(1-t)*s+t*e}function Yo(s){return(s&s-1)===0&&s!==0}function hh(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}class Z{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Z.prototype.isVector2=!0;class dt{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,o,a,c,l){const h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=o,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],p=n[5],g=n[8],x=i[0],v=i[3],m=i[6],f=i[1],T=i[4],y=i[7],E=i[2],A=i[5],L=i[8];return r[0]=o*x+a*f+c*E,r[3]=o*v+a*T+c*A,r[6]=o*m+a*y+c*L,r[1]=l*x+h*f+u*E,r[4]=l*v+h*T+u*A,r[7]=l*m+h*y+u*L,r[2]=d*x+p*f+g*E,r[5]=d*v+p*T+g*A,r[8]=d*m+p*y+g*L,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8];return t*o*h-t*a*l-n*r*h+n*a*c+i*r*l-i*o*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=h*o-a*l,d=a*c-h*r,p=l*r-o*c,g=t*u+n*d+i*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=u*x,e[1]=(i*l-h*n)*x,e[2]=(a*n-i*o)*x,e[3]=d*x,e[4]=(h*t-i*c)*x,e[5]=(i*r-a*t)*x,e[6]=p*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,o,a){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,r=i[0],o=i[3],a=i[6],c=i[1],l=i[4],h=i[7];return i[0]=t*r+n*c,i[3]=t*o+n*l,i[6]=t*a+n*h,i[1]=-n*r+t*c,i[4]=-n*o+t*l,i[7]=-n*a+t*h,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const 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){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}dt.prototype.isMatrix3=!0;function cl(s){for(let e=s.length-1;e>=0;--e)if(s[e]>65535)return!0;return!1}function Ni(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}const hl={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},Pt={h:0,s:0,l:0},Yi={h:0,s:0,l:0};function ts(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}function ii(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function ns(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}class me{constructor(e,t,n){return t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=ch(e,1),t=wt(t,0,1),n=wt(n,0,1),t===0)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=ts(r,i,e+1/3),this.g=ts(r,i,e),this.b=ts(r,i,e-1/3)}return this}setStyle(e){function t(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let i;const r=n[1],o=n[2];switch(r){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[4]),this;if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[4]),this;break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const a=parseFloat(i[1])/360,c=parseInt(i[2],10)/100,l=parseInt(i[3],10)/100;return t(i[4]),this.setHSL(a,c,l)}break}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const i=n[1],r=i.length;if(r===3)return this.r=parseInt(i.charAt(0)+i.charAt(0),16)/255,this.g=parseInt(i.charAt(1)+i.charAt(1),16)/255,this.b=parseInt(i.charAt(2)+i.charAt(2),16)/255,this;if(r===6)return this.r=parseInt(i.charAt(0)+i.charAt(1),16)/255,this.g=parseInt(i.charAt(2)+i.charAt(3),16)/255,this.b=parseInt(i.charAt(4)+i.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=hl[e.toLowerCase()];return t!==void 0?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ii(e.r),this.g=ii(e.g),this.b=ii(e.b),this}copyLinearToSRGB(e){return this.r=ns(e.r),this.g=ns(e.g),this.b=ns(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return this.r*255<<16^this.g*255<<8^this.b*255<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,n=this.g,i=this.b,r=Math.max(t,n,i),o=Math.min(t,n,i);let a,c;const l=(o+r)/2;if(o===r)a=0,c=0;else{const h=r-o;switch(c=l<=.5?h/(r+o):h/(2-r-o),r){case t:a=(n-i)/h+(n<i?6:0);break;case n:a=(i-t)/h+2;break;case i:a=(t-n)/h+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getStyle(){return"rgb("+(this.r*255|0)+","+(this.g*255|0)+","+(this.b*255|0)+")"}offsetHSL(e,t,n){return this.getHSL(Pt),Pt.h+=e,Pt.s+=t,Pt.l+=n,this.setHSL(Pt.h,Pt.s,Pt.l),this}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(Pt),e.getHSL(Yi);const n=es(Pt.h,Yi.h,t),i=es(Pt.s,Yi.s,t),r=es(Pt.l,Yi.l,t);return this.setHSL(n,i,r),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}}me.NAMES=hl;me.prototype.isColor=!0;me.prototype.r=1;me.prototype.g=1;me.prototype.b=1;let Pn;class Ln{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Pn===void 0&&(Pn=Ni("canvas")),Pn.width=e.width,Pn.height=e.height;const n=Pn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Pn}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=Ni("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=ii(r[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ii(t[n]/255)*255):t[n]=ii(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let uh=0;class lt extends Cn{constructor(e=lt.DEFAULT_IMAGE,t=lt.DEFAULT_MAPPING,n=St,i=St,r=ut,o=zr,a=xt,c=hn,l=1,h=mn){super(),Object.defineProperty(this,"id",{value:uh++}),this.uuid=Ht(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Z(0,0),this.repeat=new Z(1,1),this.center=new Z(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new dt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(this.image!==void 0){const i=this.image;if(i.uuid===void 0&&(i.uuid=Ht()),!t&&e.images[i.uuid]===void 0){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(is(i[o].image)):r.push(is(i[o]))}else r=is(i);e.images[i.uuid]={uuid:i.uuid,url:r}}n.image=i.uuid}return JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==al)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case zs:e.x=e.x-Math.floor(e.x);break;case St:e.x=e.x<0?0:1;break;case Us: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 zs:e.y=e.y-Math.floor(e.y);break;case St:e.y=e.y<0?0:1;break;case Us: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++}}lt.DEFAULT_IMAGE=void 0;lt.DEFAULT_MAPPING=al;lt.prototype.isTexture=!0;function is(s){return typeof HTMLImageElement!="undefined"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&s instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&s instanceof ImageBitmap?Ln.getDataURL(s):s.data?{data:Array.prototype.slice.call(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}class ke{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],p=c[5],g=c[9],x=c[2],v=c[6],m=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(g-v)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(g+v)<.1&&Math.abs(l+p+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const T=(l+1)/2,y=(p+1)/2,E=(m+1)/2,A=(h+d)/4,L=(u+x)/4,j=(g+v)/4;return T>y&&T>E?T<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(T),i=A/n,r=L/n):y>E?y<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(y),n=A/i,r=j/i):E<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(E),n=L/r,i=j/r),this.set(n,i,r,t),this}let f=Math.sqrt((v-g)*(v-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(f)<.001&&(f=1),this.x=(v-g)/f,this.y=(u-x)/f,this.z=(d-h)/f,this.w=Math.acos((l+p+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}ke.prototype.isVector4=!0;class At extends Cn{constructor(e,t,n={}){super(),this.width=e,this.height=t,this.depth=1,this.scissor=new ke(0,0,e,t),this.scissorTest=!1,this.viewport=new ke(0,0,e,t),this.texture=new lt(void 0,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.image={width:e,height:t,depth:1},this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:ut,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null}setTexture(e){e.image={width:this.width,height:this.height,depth:this.depth},this.texture=e}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.image=Object.assign({},e.texture.image),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}At.prototype.isWebGLRenderTarget=!0;class dh extends At{constructor(e,t,n){super(e,t);const i=this.texture;this.texture=[];for(let r=0;r<n;r++)this.texture[r]=i.clone()}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.texture.length;i<r;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone();return this}}dh.prototype.isWebGLMultipleRenderTargets=!0;class Ks extends At{constructor(e,t,n={}){super(e,t,n),this.samples=4,this.ignoreDepthForMultisampleCopy=n.ignoreDepth!==void 0?n.ignoreDepth:!0,this.useRenderToTexture=n.useRenderToTexture!==void 0?n.useRenderToTexture:!1,this.useRenderbuffer=this.useRenderToTexture===!1}copy(e){return super.copy.call(this,e),this.samples=e.samples,this.useRenderToTexture=e.useRenderToTexture,this.useRenderbuffer=e.useRenderbuffer,this}}Ks.prototype.isWebGLMultisampleRenderTarget=!0;class vt{constructor(e=0,t=0,n=0,i=1){this._x=e,this._y=t,this._z=n,this._w=i}static slerp(e,t,n,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(e,t,i)}static slerpFlat(e,t,n,i,r,o,a){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3];const d=r[o+0],p=r[o+1],g=r[o+2],x=r[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=d,e[t+1]=p,e[t+2]=g,e[t+3]=x;return}if(u!==x||c!==d||l!==p||h!==g){let v=1-a;const m=c*d+l*p+h*g+u*x,f=m>=0?1:-1,T=1-m*m;if(T>Number.EPSILON){const E=Math.sqrt(T),A=Math.atan2(E,m*f);v=Math.sin(v*A)/E,a=Math.sin(a*A)/E}const y=a*f;if(c=c*v+d*y,l=l*v+p*y,h=h*v+g*y,u=u*v+x*y,v===1-a){const E=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=E,l*=E,h*=E,u*=E}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[o],d=r[o+1],p=r[o+2],g=r[o+3];return e[t]=a*g+h*u+c*p-l*d,e[t+1]=c*g+h*d+l*u-a*p,e[t+2]=l*g+h*p+a*d-c*u,e[t+3]=h*g-a*u-c*d-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),h=a(i/2),u=a(r/2),d=c(n/2),p=c(i/2),g=c(r/2);switch(o){case"XYZ":this._x=d*h*u+l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u-d*p*g;break;case"YXZ":this._x=d*h*u+l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u+d*p*g;break;case"ZXY":this._x=d*h*u-l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u-d*p*g;break;case"ZYX":this._x=d*h*u-l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u+d*p*g;break;case"YZX":this._x=d*h*u+l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u-d*p*g;break;case"XZY":this._x=d*h*u-l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u+d*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const 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){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+a+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(o-i)*p}else if(n>a&&n>u){const p=2*Math.sqrt(1+n-a-u);this._w=(h-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+l)/p}else if(a>u){const p=2*Math.sqrt(1+a-n-u);this._w=(r-l)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+h)/p}else{const p=2*Math.sqrt(1+u-n-a);this._w=(o-i)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(wt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+o*a+i*l-r*c,this._y=i*h+o*c+r*a-n*l,this._z=r*h+o*l+n*c-i*a,this._w=o*h-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const c=1-a*a;if(c<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(c),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}vt.prototype.isQuaternion=!0;class w{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Jo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Jo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=c*t+o*i-a*n,h=c*n+a*t-r*i,u=c*i+r*n-o*t,d=-r*t-o*n-a*i;return this.x=l*c+d*-r+h*-a-u*-o,this.y=h*c+d*-o+u*-r-l*-a,this.z=u*c+d*-a+l*-o-h*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return rs.copy(this).projectOnVector(e),this.sub(rs)}reflect(e){return this.sub(rs.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(wt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const 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){const 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){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}w.prototype.isVector3=!0;const rs=new w,Jo=new vt;class Lt{constructor(e=new w(1/0,1/0,1/0),t=new w(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0;for(let c=0,l=e.length;c<l;c+=3){const h=e[c],u=e[c+1],d=e[c+2];h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>r&&(r=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(r,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0;for(let c=0,l=e.count;c<l;c++){const h=e.getX(c),u=e.getY(c),d=e.getZ(c);h<t&&(t=h),u<n&&(n=u),d<i&&(i=d),h>r&&(r=h),u>o&&(o=u),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(r,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=yn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0)if(t&&n.attributes!=null&&n.attributes.position!==void 0){const r=n.attributes.position;for(let o=0,a=r.count;o<a;o++)yn.fromBufferAttribute(r,o).applyMatrix4(e.matrixWorld),this.expandByPoint(yn)}else n.boundingBox===null&&n.computeBoundingBox(),ss.copy(n.boundingBox),ss.applyMatrix4(e.matrixWorld),this.union(ss);const i=e.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],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,yn),yn.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(_i),Ji.subVectors(this.max,_i),Dn.subVectors(e.a,_i),In.subVectors(e.b,_i),Fn.subVectors(e.c,_i),Qt.subVectors(In,Dn),en.subVectors(Fn,In),Mn.subVectors(Dn,Fn);let t=[0,-Qt.z,Qt.y,0,-en.z,en.y,0,-Mn.z,Mn.y,Qt.z,0,-Qt.x,en.z,0,-en.x,Mn.z,0,-Mn.x,-Qt.y,Qt.x,0,-en.y,en.x,0,-Mn.y,Mn.x,0];return!os(t,Dn,In,Fn,Ji)||(t=[1,0,0,0,1,0,0,0,1],!os(t,Dn,In,Fn,Ji))?!1:(Zi.crossVectors(Qt,en),t=[Zi.x,Zi.y,Zi.z],os(t,Dn,In,Fn,Ji))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return yn.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(yn).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:(qt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qt),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)}}Lt.prototype.isBox3=!0;const qt=[new w,new w,new w,new w,new w,new w,new w,new w],yn=new w,ss=new Lt,Dn=new w,In=new w,Fn=new w,Qt=new w,en=new w,Mn=new w,_i=new w,Ji=new w,Zi=new w,bn=new w;function os(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){bn.fromArray(s,r);const a=i.x*Math.abs(bn.x)+i.y*Math.abs(bn.y)+i.z*Math.abs(bn.z),c=e.dot(bn),l=t.dot(bn),h=n.dot(bn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}const fh=new Lt,Zo=new w,$i=new w,as=new w;class hi{constructor(e=new w,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):fh.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;r<o;r++)i=Math.max(i,n.distanceToSquared(e[r]));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){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){as.subVectors(e,this.center);const t=as.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(as.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?$i.set(0,0,1).multiplyScalar(e.radius):$i.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Zo.copy(e.center).add($i)),this.expandByPoint(Zo.copy(e.center).sub($i)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Xt=new w,ls=new w,Ki=new w,tn=new w,cs=new w,Qi=new w,hs=new w;class ui{constructor(e=new w,t=new w(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Xt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Xt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Xt.copy(this.direction).multiplyScalar(t).add(this.origin),Xt.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){ls.copy(e).add(t).multiplyScalar(.5),Ki.copy(t).sub(e).normalize(),tn.copy(this.origin).sub(ls);const r=e.distanceTo(t)*.5,o=-this.direction.dot(Ki),a=tn.dot(this.direction),c=-tn.dot(Ki),l=tn.lengthSq(),h=Math.abs(1-o*o);let u,d,p,g;if(h>0)if(u=o*c-a,d=o*a-c,g=r*h,u>=0)if(d>=-g)if(d<=g){const x=1/h;u*=x,d*=x,p=u*(u+o*d+2*a)+d*(o*u+d+2*c)+l}else d=r,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+l;else d<=-g?(u=Math.max(0,-(-o*r+a)),d=u>0?-r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l):d<=g?(u=0,d=Math.min(Math.max(-r,-c),r),p=d*(d+2*c)+l):(u=Math.max(0,-(o*r+a)),d=u>0?r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l);else d=o>0?-r:r,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(Ki).multiplyScalar(d).add(ls),p}intersectSphere(e,t){Xt.subVectors(e.center,this.origin);const n=Xt.dot(this.direction),i=Xt.dot(Xt)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,c=n+o;return a<0&&c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,o=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,o=(e.min.y-d.y)*h),n>o||r>i||((r>n||n!==n)&&(n=r),(o<i||i!==i)&&(i=o),u>=0?(a=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Xt)!==null}intersectTriangle(e,t,n,i,r){cs.subVectors(t,e),Qi.subVectors(n,e),hs.crossVectors(cs,Qi);let o=this.direction.dot(hs),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;tn.subVectors(this.origin,e);const c=a*this.direction.dot(Qi.crossVectors(tn,Qi));if(c<0)return null;const l=a*this.direction.dot(cs.cross(tn));if(l<0||c+l>o)return null;const h=-a*tn.dot(hs);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ve{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,r,o,a,c,l,h,u,d,p,g,x,v){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=o,m[9]=a,m[13]=c,m[2]=l,m[6]=h,m[10]=u,m[14]=d,m[3]=p,m[7]=g,m[11]=x,m[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ve().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Nn.setFromMatrixColumn(e,0).length(),r=1/Nn.setFromMatrixColumn(e,1).length(),o=1/Nn.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]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=o*h,p=o*u,g=a*h,x=a*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=p+g*l,t[5]=d-x*l,t[9]=-a*c,t[2]=x-d*l,t[6]=g+p*l,t[10]=o*c}else if(e.order==="YXZ"){const d=c*h,p=c*u,g=l*h,x=l*u;t[0]=d+x*a,t[4]=g*a-p,t[8]=o*l,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=p*a-g,t[6]=x+d*a,t[10]=o*c}else if(e.order==="ZXY"){const d=c*h,p=c*u,g=l*h,x=l*u;t[0]=d-x*a,t[4]=-o*u,t[8]=g+p*a,t[1]=p+g*a,t[5]=o*h,t[9]=x-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const d=o*h,p=o*u,g=a*h,x=a*u;t[0]=c*h,t[4]=g*l-p,t[8]=d*l+x,t[1]=c*u,t[5]=x*l+d,t[9]=p*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const d=o*c,p=o*l,g=a*c,x=a*l;t[0]=c*h,t[4]=x-d*u,t[8]=g*u+p,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=p*u+g,t[10]=d-x*u}else if(e.order==="XZY"){const d=o*c,p=o*l,g=a*c,x=a*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+x,t[5]=o*h,t[9]=p*u-g,t[2]=g*u-p,t[6]=a*h,t[10]=x*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(ph,e,mh)}lookAt(e,t,n){const i=this.elements;return Mt.subVectors(e,t),Mt.lengthSq()===0&&(Mt.z=1),Mt.normalize(),nn.crossVectors(n,Mt),nn.lengthSq()===0&&(Math.abs(n.z)===1?Mt.x+=1e-4:Mt.z+=1e-4,Mt.normalize(),nn.crossVectors(n,Mt)),nn.normalize(),er.crossVectors(Mt,nn),i[0]=nn.x,i[4]=er.x,i[8]=Mt.x,i[1]=nn.y,i[5]=er.y,i[9]=Mt.y,i[2]=nn.z,i[6]=er.z,i[10]=Mt.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],p=n[13],g=n[2],x=n[6],v=n[10],m=n[14],f=n[3],T=n[7],y=n[11],E=n[15],A=i[0],L=i[4],j=i[8],te=i[12],Y=i[1],_=i[5],R=i[9],P=i[13],B=i[2],F=i[6],I=i[10],H=i[14],J=i[3],ce=i[7],U=i[11],X=i[15];return r[0]=o*A+a*Y+c*B+l*J,r[4]=o*L+a*_+c*F+l*ce,r[8]=o*j+a*R+c*I+l*U,r[12]=o*te+a*P+c*H+l*X,r[1]=h*A+u*Y+d*B+p*J,r[5]=h*L+u*_+d*F+p*ce,r[9]=h*j+u*R+d*I+p*U,r[13]=h*te+u*P+d*H+p*X,r[2]=g*A+x*Y+v*B+m*J,r[6]=g*L+x*_+v*F+m*ce,r[10]=g*j+x*R+v*I+m*U,r[14]=g*te+x*P+v*H+m*X,r[3]=f*A+T*Y+y*B+E*J,r[7]=f*L+T*_+y*F+E*ce,r[11]=f*j+T*R+y*I+E*U,r[15]=f*te+T*P+y*H+E*X,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],p=e[14],g=e[3],x=e[7],v=e[11],m=e[15];return g*(+r*c*u-i*l*u-r*a*d+n*l*d+i*a*p-n*c*p)+x*(+t*c*p-t*l*d+r*o*d-i*o*p+i*l*h-r*c*h)+v*(+t*l*u-t*a*p-r*o*u+n*o*p+r*a*h-n*l*h)+m*(-i*a*h-t*c*u+t*a*d+i*o*u-n*o*d+n*c*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const 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(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],p=e[11],g=e[12],x=e[13],v=e[14],m=e[15],f=u*v*l-x*d*l+x*c*p-a*v*p-u*c*m+a*d*m,T=g*d*l-h*v*l-g*c*p+o*v*p+h*c*m-o*d*m,y=h*x*l-g*u*l+g*a*p-o*x*p-h*a*m+o*u*m,E=g*u*c-h*x*c-g*a*d+o*x*d+h*a*v-o*u*v,A=t*f+n*T+i*y+r*E;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const L=1/A;return e[0]=f*L,e[1]=(x*d*r-u*v*r-x*i*p+n*v*p+u*i*m-n*d*m)*L,e[2]=(a*v*r-x*c*r+x*i*l-n*v*l-a*i*m+n*c*m)*L,e[3]=(u*c*r-a*d*r-u*i*l+n*d*l+a*i*p-n*c*p)*L,e[4]=T*L,e[5]=(h*v*r-g*d*r+g*i*p-t*v*p-h*i*m+t*d*m)*L,e[6]=(g*c*r-o*v*r-g*i*l+t*v*l+o*i*m-t*c*m)*L,e[7]=(o*d*r-h*c*r+h*i*l-t*d*l-o*i*p+t*c*p)*L,e[8]=y*L,e[9]=(g*u*r-h*x*r-g*n*p+t*x*p+h*n*m-t*u*m)*L,e[10]=(o*x*r-g*a*r+g*n*l-t*x*l-o*n*m+t*a*m)*L,e[11]=(h*a*r-o*u*r-h*n*l+t*u*l+o*n*p-t*a*p)*L,e[12]=E*L,e[13]=(h*x*i-g*u*i+g*n*d-t*x*d-h*n*v+t*u*v)*L,e[14]=(g*a*i-o*x*i-g*n*c+t*x*c+o*n*v-t*a*v)*L,e[15]=(o*u*i-h*a*i+h*n*c-t*u*c-o*n*d+t*a*d)*L,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,h=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,h*a+n,h*c-i*o,0,l*c-i*a,h*c+i*o,r*c*c+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,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,h=o+o,u=a+a,d=r*l,p=r*h,g=r*u,x=o*h,v=o*u,m=a*u,f=c*l,T=c*h,y=c*u,E=n.x,A=n.y,L=n.z;return i[0]=(1-(x+m))*E,i[1]=(p+y)*E,i[2]=(g-T)*E,i[3]=0,i[4]=(p-y)*A,i[5]=(1-(d+m))*A,i[6]=(v+f)*A,i[7]=0,i[8]=(g+T)*L,i[9]=(v-f)*L,i[10]=(1-(d+x))*L,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Nn.set(i[0],i[1],i[2]).length();const o=Nn.set(i[4],i[5],i[6]).length(),a=Nn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Dt.copy(this);const l=1/r,h=1/o,u=1/a;return Dt.elements[0]*=l,Dt.elements[1]*=l,Dt.elements[2]*=l,Dt.elements[4]*=h,Dt.elements[5]*=h,Dt.elements[6]*=h,Dt.elements[8]*=u,Dt.elements[9]*=u,Dt.elements[10]*=u,t.setFromRotationMatrix(Dt),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,c=2*r/(t-e),l=2*r/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i),d=-(o+r)/(o-r),p=-2*o*r/(o-r);return a[0]=c,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,r,o){const a=this.elements,c=1/(t-e),l=1/(n-i),h=1/(o-r),u=(t+e)*c,d=(n+i)*l,p=(o+r)*h;return a[0]=2*c,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const 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){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}ve.prototype.isMatrix4=!0;const Nn=new w,Dt=new ve,ph=new w(0,0,0),mh=new w(1,1,1),nn=new w,er=new w,Mt=new w,$o=new ve,Ko=new vt;class gn{constructor(e=0,t=0,n=0,i=gn.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(wt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-wt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(wt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-wt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(wt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-wt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return $o.makeRotationFromQuaternion(e),this.setFromRotationMatrix($o,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ko.setFromEuler(this),this.setFromQuaternion(Ko,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new w(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}gn.prototype.isEuler=!0;gn.DefaultOrder="XYZ";gn.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ul{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let gh=0;const Qo=new w,Bn=new vt,jt=new ve,tr=new w,vi=new w,xh=new w,_h=new vt,ea=new w(1,0,0),ta=new w(0,1,0),na=new w(0,0,1),vh={type:"added"},ia={type:"removed"};class Ue extends Cn{constructor(){super(),Object.defineProperty(this,"id",{value:gh++}),this.uuid=Ht(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ue.DefaultUp.clone();const e=new w,t=new gn,n=new vt,i=new w(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),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 ve},normalMatrix:{value:new dt}}),this.matrix=new ve,this.matrixWorld=new ve,this.matrixAutoUpdate=Ue.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new ul,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}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 Bn.setFromAxisAngle(e,t),this.quaternion.multiply(Bn),this}rotateOnWorldAxis(e,t){return Bn.setFromAxisAngle(e,t),this.quaternion.premultiply(Bn),this}rotateX(e){return this.rotateOnAxis(ea,e)}rotateY(e){return this.rotateOnAxis(ta,e)}rotateZ(e){return this.rotateOnAxis(na,e)}translateOnAxis(e,t){return Qo.copy(e).applyQuaternion(this.quaternion),this.position.add(Qo.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ea,e)}translateY(e){return this.translateOnAxis(ta,e)}translateZ(e){return this.translateOnAxis(na,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(jt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?tr.copy(e):tr.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),vi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?jt.lookAt(vi,tr,this.up):jt.lookAt(tr,vi,this.up),this.quaternion.setFromRotationMatrix(jt),i&&(jt.extractRotation(i.matrixWorld),Bn.setFromRotationMatrix(jt),this.quaternion.premultiply(Bn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(vh)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(ia)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(ia)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),jt.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),jt.multiply(e.parent.matrixWorld)),e.applyMatrix4(jt),this.add(e),e.updateWorldMatrix(!1,!0),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++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vi,e,xh),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vi,_h,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const 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),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.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()));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.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&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));i.material=a}else i.material=r(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++){const c=this.animations[a];i.animations.push(r(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),h=o(e.images),u=o(e.shapes),d=o(e.skeletons),p=o(e.animations);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p)}return n.object=i,n;function o(a){const c=[];for(const l in a){const h=a[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}Ue.DefaultUp=new w(0,1,0);Ue.DefaultMatrixAutoUpdate=!0;Ue.prototype.isObject3D=!0;const It=new w,Yt=new w,us=new w,Jt=new w,zn=new w,Un=new w,ra=new w,ds=new w,fs=new w,ps=new w;class tt{constructor(e=new w,t=new w,n=new w){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),It.subVectors(e,t),i.cross(It);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){It.subVectors(i,t),Yt.subVectors(n,t),us.subVectors(e,t);const o=It.dot(It),a=It.dot(Yt),c=It.dot(us),l=Yt.dot(Yt),h=Yt.dot(us),u=o*l-a*a;if(u===0)return r.set(-2,-1,-1);const d=1/u,p=(l*c-a*h)*d,g=(o*h-a*c)*d;return r.set(1-p-g,g,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Jt),Jt.x>=0&&Jt.y>=0&&Jt.x+Jt.y<=1}static getUV(e,t,n,i,r,o,a,c){return this.getBarycoord(e,t,n,i,Jt),c.set(0,0),c.addScaledVector(r,Jt.x),c.addScaledVector(o,Jt.y),c.addScaledVector(a,Jt.z),c}static isFrontFacing(e,t,n,i){return It.subVectors(n,t),Yt.subVectors(e,t),It.cross(Yt).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return It.subVectors(this.c,this.b),Yt.subVectors(this.a,this.b),It.cross(Yt).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return tt.getUV(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return tt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;zn.subVectors(i,n),Un.subVectors(r,n),ds.subVectors(e,n);const c=zn.dot(ds),l=Un.dot(ds);if(c<=0&&l<=0)return t.copy(n);fs.subVectors(e,i);const h=zn.dot(fs),u=Un.dot(fs);if(h>=0&&u<=h)return t.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return o=c/(c-h),t.copy(n).addScaledVector(zn,o);ps.subVectors(e,r);const p=zn.dot(ps),g=Un.dot(ps);if(g>=0&&p<=g)return t.copy(r);const x=p*l-c*g;if(x<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(n).addScaledVector(Un,a);const v=h*g-p*u;if(v<=0&&u-h>=0&&p-g>=0)return ra.subVectors(r,i),a=(u-h)/(u-h+(p-g)),t.copy(i).addScaledVector(ra,a);const m=1/(v+x+d);return o=x*m,a=d*m,t.copy(n).addScaledVector(zn,o).addScaledVector(Un,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let yh=0;class ct extends Cn{constructor(){super(),Object.defineProperty(this,"id",{value:yh++}),this.uuid=Ht(),this.name="",this.type="Material",this.fog=!0,this.blending=Li,this.side=Di,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=sl,this.blendDst=ol,this.blendEquation=Zn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Fs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Kr,this.stencilZFail=Kr,this.stencilZPass=Kr,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===rl;continue}const i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==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&&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.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.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.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!==Li&&(n.blending=this.blending),this.side!==Di&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(r){const o=[];for(const a in r){const c=r[a];delete c.metadata,o.push(c)}return o}if(t){const r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}ct.prototype.isMaterial=!0;class Qs extends ct{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new me(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Nr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Qs.prototype.isMeshBasicMaterial=!0;const qe=new w,nr=new Z;class ot{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=Fi,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}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}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new me),t[n++]=o.r,t[n++]=o.g,t[n++]=o.b}return this}copyVector2sArray(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new Z),t[n++]=o.x,t[n++]=o.y}return this}copyVector3sArray(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new w),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z}return this}copyVector4sArray(e){const t=this.array;let n=0;for(let i=0,r=e.length;i<r;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new ke),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z,t[n++]=o.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)nr.fromBufferAttribute(this,t),nr.applyMatrix3(e),this.setXY(t,nr.x,nr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)qe.fromBufferAttribute(this,t),qe.applyMatrix3(e),this.setXYZ(t,qe.x,qe.y,qe.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)qe.x=this.getX(t),qe.y=this.getY(t),qe.z=this.getZ(t),qe.applyMatrix4(e),this.setXYZ(t,qe.x,qe.y,qe.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qe.x=this.getX(t),qe.y=this.getY(t),qe.z=this.getZ(t),qe.applyNormalMatrix(e),this.setXYZ(t,qe.x,qe.y,qe.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qe.x=this.getX(t),qe.y=this.getY(t),qe.z=this.getZ(t),qe.transformDirection(e),this.setXYZ(t,qe.x,qe.y,qe.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Fi&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}}ot.prototype.isBufferAttribute=!0;class dl extends ot{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class fl extends ot{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Mh extends ot{constructor(e,t,n){super(new Uint16Array(e),t,n)}}Mh.prototype.isFloat16BufferAttribute=!0;class Je extends ot{constructor(e,t,n){super(new Float32Array(e),t,n)}}let bh=0;const Et=new ve,ms=new Ue,On=new w,bt=new Lt,yi=new Lt,at=new w;class Xe extends Cn{constructor(){super(),Object.defineProperty(this,"id",{value:bh++}),this.uuid=Ht(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(cl(e)?fl:dl)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new dt().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const 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 Et.makeRotationFromQuaternion(e),this.applyMatrix4(Et),this}rotateX(e){return Et.makeRotationX(e),this.applyMatrix4(Et),this}rotateY(e){return Et.makeRotationY(e),this.applyMatrix4(Et),this}rotateZ(e){return Et.makeRotationZ(e),this.applyMatrix4(Et),this}translate(e,t,n){return Et.makeTranslation(e,t,n),this.applyMatrix4(Et),this}scale(e,t,n){return Et.makeScale(e,t,n),this.applyMatrix4(Et),this}lookAt(e){return ms.lookAt(e),ms.updateMatrix(),this.applyMatrix4(ms.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(On).negate(),this.translate(On.x,On.y,On.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Je(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Lt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new w(-1/0,-1/0,-1/0),new w(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++){const r=t[n];bt.setFromBufferAttribute(r),this.morphTargetsRelative?(at.addVectors(this.boundingBox.min,bt.min),this.boundingBox.expandByPoint(at),at.addVectors(this.boundingBox.max,bt.max),this.boundingBox.expandByPoint(at)):(this.boundingBox.expandByPoint(bt.min),this.boundingBox.expandByPoint(bt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new w,1/0);return}if(e){const n=this.boundingSphere.center;if(bt.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];yi.setFromBufferAttribute(a),this.morphTargetsRelative?(at.addVectors(bt.min,yi.min),bt.expandByPoint(at),at.addVectors(bt.max,yi.max),bt.expandByPoint(at)):(bt.expandByPoint(yi.min),bt.expandByPoint(yi.max))}bt.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)at.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(at));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)at.fromBufferAttribute(a,l),c&&(On.fromBufferAttribute(e,l),at.add(On)),i=Math.max(i,n.distanceToSquared(at))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.array,i=t.position.array,r=t.normal.array,o=t.uv.array,a=i.length/3;t.tangent===void 0&&this.setAttribute("tangent",new ot(new Float32Array(4*a),4));const c=t.tangent.array,l=[],h=[];for(let Y=0;Y<a;Y++)l[Y]=new w,h[Y]=new w;const u=new w,d=new w,p=new w,g=new Z,x=new Z,v=new Z,m=new w,f=new w;function T(Y,_,R){u.fromArray(i,Y*3),d.fromArray(i,_*3),p.fromArray(i,R*3),g.fromArray(o,Y*2),x.fromArray(o,_*2),v.fromArray(o,R*2),d.sub(u),p.sub(u),x.sub(g),v.sub(g);const P=1/(x.x*v.y-v.x*x.y);!isFinite(P)||(m.copy(d).multiplyScalar(v.y).addScaledVector(p,-x.y).multiplyScalar(P),f.copy(p).multiplyScalar(x.x).addScaledVector(d,-v.x).multiplyScalar(P),l[Y].add(m),l[_].add(m),l[R].add(m),h[Y].add(f),h[_].add(f),h[R].add(f))}let y=this.groups;y.length===0&&(y=[{start:0,count:n.length}]);for(let Y=0,_=y.length;Y<_;++Y){const R=y[Y],P=R.start,B=R.count;for(let F=P,I=P+B;F<I;F+=3)T(n[F+0],n[F+1],n[F+2])}const E=new w,A=new w,L=new w,j=new w;function te(Y){L.fromArray(r,Y*3),j.copy(L);const _=l[Y];E.copy(_),E.sub(L.multiplyScalar(L.dot(_))).normalize(),A.crossVectors(j,_);const P=A.dot(h[Y])<0?-1:1;c[Y*4]=E.x,c[Y*4+1]=E.y,c[Y*4+2]=E.z,c[Y*4+3]=P}for(let Y=0,_=y.length;Y<_;++Y){const R=y[Y],P=R.start,B=R.count;for(let F=P,I=P+B;F<I;F+=3)te(n[F+0]),te(n[F+1]),te(n[F+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ot(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const i=new w,r=new w,o=new w,a=new w,c=new w,l=new w,h=new w,u=new w;if(e)for(let d=0,p=e.count;d<p;d+=3){const g=e.getX(d+0),x=e.getX(d+1),v=e.getX(d+2);i.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,v),h.subVectors(o,r),u.subVectors(i,r),h.cross(u),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,v),a.add(h),c.add(h),l.add(h),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(v,l.x,l.y,l.z)}else for(let d=0,p=t.count;d<p;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),h.subVectors(o,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const n=this.attributes;for(const i in n){if(e.attributes[i]===void 0)continue;const o=n[i].array,a=e.attributes[i],c=a.array,l=a.itemSize*t,h=Math.min(c.length,o.length-l);for(let u=0,d=l;u<h;u++,d++)o[d]=c[u]}return this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)at.fromBufferAttribute(e,t),at.normalize(),e.setXYZ(t,at.x,at.y,at.z)}toNonIndexed(){function e(a,c){const l=a.array,h=a.itemSize,u=a.normalized,d=new l.constructor(c.length*h);let p=0,g=0;for(let x=0,v=c.length;x<v;x++){a.isInterleavedBufferAttribute?p=c[x]*a.data.stride+a.offset:p=c[x]*h;for(let m=0;m<h;m++)d[g++]=l[p++]}return new ot(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Xe,n=this.index.array,i=this.attributes;for(const a in i){const c=i[a],l=e(c,n);t.setAttribute(a,l)}const r=this.morphAttributes;for(const a in r){const c=[],l=r[a];for(let h=0,u=l.length;h<u;h++){const d=l[h],p=e(d,n);c.push(p)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const p=l[u];h.push(p.toJSON(e.data))}h.length>0&&(i[c]=h,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,h=o.length;l<h;l++){const u=o[l];this.addGroup(u.start,u.count,u.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}Xe.prototype.isBufferGeometry=!0;const sa=new ve,Hn=new ui,gs=new hi,rn=new w,sn=new w,on=new w,xs=new w,_s=new w,vs=new w,ir=new w,rr=new w,sr=new w,or=new Z,ar=new Z,lr=new Z,ys=new w,cr=new w;class st extends Ue{constructor(e=new Xe,t=new Qs){super(),this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(i===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),gs.copy(n.boundingSphere),gs.applyMatrix4(r),e.ray.intersectsSphere(gs)===!1)||(sa.copy(r).invert(),Hn.copy(e.ray).applyMatrix4(sa),n.boundingBox!==null&&Hn.intersectsBox(n.boundingBox)===!1))return;let o;if(n.isBufferGeometry){const a=n.index,c=n.attributes.position,l=n.morphAttributes.position,h=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,p=n.groups,g=n.drawRange;if(a!==null)if(Array.isArray(i))for(let x=0,v=p.length;x<v;x++){const m=p[x],f=i[m.materialIndex],T=Math.max(m.start,g.start),y=Math.min(a.count,Math.min(m.start+m.count,g.start+g.count));for(let E=T,A=y;E<A;E+=3){const L=a.getX(E),j=a.getX(E+1),te=a.getX(E+2);o=hr(this,f,e,Hn,c,l,h,u,d,L,j,te),o&&(o.faceIndex=Math.floor(E/3),o.face.materialIndex=m.materialIndex,t.push(o))}}else{const x=Math.max(0,g.start),v=Math.min(a.count,g.start+g.count);for(let m=x,f=v;m<f;m+=3){const T=a.getX(m),y=a.getX(m+1),E=a.getX(m+2);o=hr(this,i,e,Hn,c,l,h,u,d,T,y,E),o&&(o.faceIndex=Math.floor(m/3),t.push(o))}}else if(c!==void 0)if(Array.isArray(i))for(let x=0,v=p.length;x<v;x++){const m=p[x],f=i[m.materialIndex],T=Math.max(m.start,g.start),y=Math.min(c.count,Math.min(m.start+m.count,g.start+g.count));for(let E=T,A=y;E<A;E+=3){const L=E,j=E+1,te=E+2;o=hr(this,f,e,Hn,c,l,h,u,d,L,j,te),o&&(o.faceIndex=Math.floor(E/3),o.face.materialIndex=m.materialIndex,t.push(o))}}else{const x=Math.max(0,g.start),v=Math.min(c.count,g.start+g.count);for(let m=x,f=v;m<f;m+=3){const T=m,y=m+1,E=m+2;o=hr(this,i,e,Hn,c,l,h,u,d,T,y,E),o&&(o.faceIndex=Math.floor(m/3),t.push(o))}}}else n.isGeometry&&console.error("THREE.Mesh.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}st.prototype.isMesh=!0;function wh(s,e,t,n,i,r,o,a){let c;if(e.side===it?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,e.side!==si,a),c===null)return null;cr.copy(a),cr.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(cr);return l<t.near||l>t.far?null:{distance:l,point:cr.clone(),object:s}}function hr(s,e,t,n,i,r,o,a,c,l,h,u){rn.fromBufferAttribute(i,l),sn.fromBufferAttribute(i,h),on.fromBufferAttribute(i,u);const d=s.morphTargetInfluences;if(r&&d){ir.set(0,0,0),rr.set(0,0,0),sr.set(0,0,0);for(let g=0,x=r.length;g<x;g++){const v=d[g],m=r[g];v!==0&&(xs.fromBufferAttribute(m,l),_s.fromBufferAttribute(m,h),vs.fromBufferAttribute(m,u),o?(ir.addScaledVector(xs,v),rr.addScaledVector(_s,v),sr.addScaledVector(vs,v)):(ir.addScaledVector(xs.sub(rn),v),rr.addScaledVector(_s.sub(sn),v),sr.addScaledVector(vs.sub(on),v)))}rn.add(ir),sn.add(rr),on.add(sr)}s.isSkinnedMesh&&(s.boneTransform(l,rn),s.boneTransform(h,sn),s.boneTransform(u,on));const p=wh(s,e,t,n,rn,sn,on,ys);if(p){a&&(or.fromBufferAttribute(a,l),ar.fromBufferAttribute(a,h),lr.fromBufferAttribute(a,u),p.uv=tt.getUV(ys,rn,sn,on,or,ar,lr,new Z)),c&&(or.fromBufferAttribute(c,l),ar.fromBufferAttribute(c,h),lr.fromBufferAttribute(c,u),p.uv2=tt.getUV(ys,rn,sn,on,or,ar,lr,new Z));const g={a:l,b:h,c:u,normal:new w,materialIndex:0};tt.getNormal(rn,sn,on,g.normal),p.face=g}return p}class ki extends Xe{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const c=[],l=[],h=[],u=[];let d=0,p=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,r,4),g("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Je(l,3)),this.setAttribute("normal",new Je(h,3)),this.setAttribute("uv",new Je(u,2));function g(x,v,m,f,T,y,E,A,L,j,te){const Y=y/L,_=E/j,R=y/2,P=E/2,B=A/2,F=L+1,I=j+1;let H=0,J=0;const ce=new w;for(let U=0;U<I;U++){const X=U*_-P;for(let ie=0;ie<F;ie++){const ue=ie*Y-R;ce[x]=ue*f,ce[v]=X*T,ce[m]=B,l.push(ce.x,ce.y,ce.z),ce[x]=0,ce[v]=0,ce[m]=A>0?1:-1,h.push(ce.x,ce.y,ce.z),u.push(ie/L),u.push(1-U/j),H+=1}}for(let U=0;U<j;U++)for(let X=0;X<L;X++){const ie=d+X+F*U,ue=d+X+F*(U+1),ge=d+(X+1)+F*(U+1),O=d+(X+1)+F*U;c.push(ie,ue,O),c.push(ue,ge,O),J+=6}a.addGroup(p,J,te),p+=J,d+=H}}static fromJSON(e){return new ki(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ai(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function pt(s){const e={};for(let t=0;t<s.length;t++){const n=ai(s[t]);for(const i in n)e[i]=n[i]}return e}const Sh={clone:ai,merge:pt};var Eh=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,Th=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class An extends ct{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=Eh,this.fragmentShader=Th,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ai(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}An.prototype.isShaderMaterial=!0;class eo extends Ue{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new ve,this.projectionMatrix=new ve,this.projectionMatrixInverse=new ve}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}eo.prototype.isCamera=!0;class gt extends eo{constructor(e=50,t=1,n=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Hs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Qr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Hs*2*Math.atan(Math.tan(Qr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Qr*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/c,t-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}gt.prototype.isPerspectiveCamera=!0;const Vn=90,Gn=1;class to extends Ue{constructor(e,t,n){if(super(),this.type="CubeCamera",n.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=n;const i=new gt(Vn,Gn,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new w(1,0,0)),this.add(i);const r=new gt(Vn,Gn,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new w(-1,0,0)),this.add(r);const o=new gt(Vn,Gn,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new w(0,1,0)),this.add(o);const a=new gt(Vn,Gn,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new w(0,-1,0)),this.add(a);const c=new gt(Vn,Gn,e,t);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new w(0,0,1)),this.add(c);const l=new gt(Vn,Gn,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new w(0,0,-1)),this.add(l)}update(e,t){this.parent===null&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,o,a,c,l]=this.children,h=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,o),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,c),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=h,n.texture.needsPMREMUpdate=!0}}class Ur extends lt{constructor(e,t,n,i,r,o,a,c,l,h){e=e!==void 0?e:[],t=t!==void 0?t:Vi,super(e,t,n,i,r,o,a,c,l,h),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Ur.prototype.isCubeTexture=!0;class pl extends At{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),t=t||{},this.texture=new Ur(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:ut}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=xt,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize( vWorldDirection );
|
|
|
|
vec2 sampleUV = equirectUv( direction );
|
|
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
}
|
|
`},i=new ki(5,5,5),r=new An({name:"CubemapFromEquirect",uniforms:ai(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:it,blending:ln});r.uniforms.tEquirect.value=t;const o=new st(i,r),a=t.minFilter;return t.minFilter===zr&&(t.minFilter=ut),new to(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}}pl.prototype.isWebGLCubeRenderTarget=!0;const Ms=new w,Ah=new w,Ch=new dt;class $t{constructor(e=new w(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Ms.subVectors(n,t).cross(Ah.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const n=e.delta(Ms),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(n).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Ch.getNormalMatrix(e),i=this.coplanarPoint(Ms).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}$t.prototype.isPlane=!0;const kn=new hi,ur=new w;class Or{constructor(e=new $t,t=new $t,n=new $t,i=new $t,r=new $t,o=new $t){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],r=n[1],o=n[2],a=n[3],c=n[4],l=n[5],h=n[6],u=n[7],d=n[8],p=n[9],g=n[10],x=n[11],v=n[12],m=n[13],f=n[14],T=n[15];return t[0].setComponents(a-i,u-c,x-d,T-v).normalize(),t[1].setComponents(a+i,u+c,x+d,T+v).normalize(),t[2].setComponents(a+r,u+l,x+p,T+m).normalize(),t[3].setComponents(a-r,u-l,x-p,T-m).normalize(),t[4].setComponents(a-o,u-h,x-g,T-f).normalize(),t[5].setComponents(a+o,u+h,x+g,T+f).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),kn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(kn)}intersectsSprite(e){return kn.center.set(0,0,0),kn.radius=.7071067811865476,kn.applyMatrix4(e.matrixWorld),this.intersectsSphere(kn)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(ur.x=i.normal.x>0?e.max.x:e.min.x,ur.y=i.normal.y>0?e.max.y:e.min.y,ur.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ur)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function ml(){let s=null,e=!1,t=null,n=null;function i(r,o){t(r,o),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function Lh(s,e){const t=e.isWebGL2,n=new WeakMap;function i(l,h){const u=l.array,d=l.usage,p=s.createBuffer();s.bindBuffer(h,p),s.bufferData(h,u,d),l.onUploadCallback();let g=5126;return u instanceof Float32Array?g=5126:u instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):u instanceof Uint16Array?l.isFloat16BufferAttribute?t?g=5131:console.warn("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2."):g=5123:u instanceof Int16Array?g=5122:u instanceof Uint32Array?g=5125:u instanceof Int32Array?g=5124:u instanceof Int8Array?g=5120:(u instanceof Uint8Array||u instanceof Uint8ClampedArray)&&(g=5121),{buffer:p,type:g,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version}}function r(l,h,u){const d=h.array,p=h.updateRange;s.bindBuffer(u,l),p.count===-1?s.bufferSubData(u,0,d):(t?s.bufferSubData(u,p.offset*d.BYTES_PER_ELEMENT,d,p.offset,p.count):s.bufferSubData(u,p.offset*d.BYTES_PER_ELEMENT,d.subarray(p.offset,p.offset+p.count)),p.count=-1)}function o(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const h=n.get(l);h&&(s.deleteBuffer(h.buffer),n.delete(l))}function c(l,h){if(l.isGLBufferAttribute){const d=n.get(l);(!d||d.version<l.version)&&n.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);u===void 0?n.set(l,i(l,h)):u.version<l.version&&(r(u.buffer,l,h),u.version=l.version)}return{get:o,remove:a,update:c}}class no extends Xe{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,h=c+1,u=e/a,d=t/c,p=[],g=[],x=[],v=[];for(let m=0;m<h;m++){const f=m*d-o;for(let T=0;T<l;T++){const y=T*u-r;g.push(y,-f,0),x.push(0,0,1),v.push(T/a),v.push(1-m/c)}}for(let m=0;m<c;m++)for(let f=0;f<a;f++){const T=f+l*m,y=f+l*(m+1),E=f+1+l*(m+1),A=f+1+l*m;p.push(T,y,A),p.push(y,E,A)}this.setIndex(p),this.setAttribute("position",new Je(g,3)),this.setAttribute("normal",new Je(x,3)),this.setAttribute("uv",new Je(v,2))}static fromJSON(e){return new no(e.width,e.height,e.widthSegments,e.heightSegments)}}var Rh=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vUv ).g;
|
|
#endif`,Ph=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,Dh=`#ifdef USE_ALPHATEST
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
#endif`,Ih=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,Fh=`#ifdef USE_AOMAP
|
|
float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
#endif
|
|
#endif`,Nh=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,Bh="vec3 transformed = vec3( position );",zh=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,Uh=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
return RECIPROCAL_PI * diffuseColor;
|
|
}
|
|
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
}
|
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
float a2 = pow2( alpha );
|
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
return 0.5 / max( gv + gl, EPSILON );
|
|
}
|
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
float a2 = pow2( alpha );
|
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
}
|
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
return F * ( V * D );
|
|
}
|
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
const float LUT_SIZE = 64.0;
|
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
float dotNV = saturate( dot( N, V ) );
|
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
return uv;
|
|
}
|
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
float l = length( f );
|
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
}
|
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
float x = dot( v1, v2 );
|
|
float y = abs( x );
|
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
float v = a / b;
|
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
return cross( v1, v2 ) * theta_sintheta;
|
|
}
|
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
vec3 lightNormal = cross( v1, v2 );
|
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
vec3 T1, T2;
|
|
T1 = normalize( V - N * dot( V, N ) );
|
|
T2 = - cross( N, T1 );
|
|
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
|
vec3 coords[ 4 ];
|
|
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
vec3 vectorFormFactor = vec3( 0.0 );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
return vec3( result );
|
|
}
|
|
float G_BlinnPhong_Implicit( ) {
|
|
return 0.25;
|
|
}
|
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
}
|
|
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
float G = G_BlinnPhong_Implicit( );
|
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
return F * ( G * D );
|
|
}
|
|
#if defined( USE_SHEEN )
|
|
float D_Charlie( float roughness, float dotNH ) {
|
|
float alpha = pow2( roughness );
|
|
float invAlpha = 1.0 / alpha;
|
|
float cos2h = dotNH * dotNH;
|
|
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
}
|
|
float V_Neubelt( float dotNV, float dotNL ) {
|
|
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
}
|
|
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float D = D_Charlie( sheenRoughness, dotNH );
|
|
float V = V_Neubelt( dotNV, dotNL );
|
|
return sheenColor * ( D * V );
|
|
}
|
|
#endif`,Oh=`#ifdef USE_BUMPMAP
|
|
uniform sampler2D bumpMap;
|
|
uniform float bumpScale;
|
|
vec2 dHdxy_fwd() {
|
|
vec2 dSTdx = dFdx( vUv );
|
|
vec2 dSTdy = dFdy( vUv );
|
|
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
|
|
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
|
|
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
|
|
return vec2( dBx, dBy );
|
|
}
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
|
|
vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
|
|
vec3 vN = surf_norm;
|
|
vec3 R1 = cross( vSigmaY, vN );
|
|
vec3 R2 = cross( vN, vSigmaX );
|
|
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
}
|
|
#endif`,Hh=`#if NUM_CLIPPING_PLANES > 0
|
|
vec4 plane;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
bool clipped = true;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
}
|
|
#pragma unroll_loop_end
|
|
if ( clipped ) discard;
|
|
#endif
|
|
#endif`,Vh=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
#endif`,Gh=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
#endif`,kh=`#if NUM_CLIPPING_PLANES > 0
|
|
vClipPosition = - mvPosition.xyz;
|
|
#endif`,Wh=`#if defined( USE_COLOR_ALPHA )
|
|
diffuseColor *= vColor;
|
|
#elif defined( USE_COLOR )
|
|
diffuseColor.rgb *= vColor;
|
|
#endif`,qh=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,Xh=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,jh=`#if defined( USE_COLOR_ALPHA )
|
|
vColor = vec4( 1.0 );
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
vColor = vec3( 1.0 );
|
|
#endif
|
|
#ifdef USE_COLOR
|
|
vColor *= color;
|
|
#endif
|
|
#ifdef USE_INSTANCING_COLOR
|
|
vColor.xyz *= instanceColor.xyz;
|
|
#endif`,Yh=`#define PI 3.141592653589793
|
|
#define PI2 6.283185307179586
|
|
#define PI_HALF 1.5707963267948966
|
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
#define RECIPROCAL_PI2 0.15915494309189535
|
|
#define EPSILON 1e-6
|
|
#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
float pow2( const in float x ) { return x*x; }
|
|
float pow3( const in float x ) { return x*x*x; }
|
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
|
|
highp float rand( const in vec2 uv ) {
|
|
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
return fract( sin( sn ) * c );
|
|
}
|
|
#ifdef HIGH_PRECISION
|
|
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
#else
|
|
float precisionSafeLength( vec3 v ) {
|
|
float maxComponent = max3( abs( v ) );
|
|
return length( v / maxComponent ) * maxComponent;
|
|
}
|
|
#endif
|
|
struct IncidentLight {
|
|
vec3 color;
|
|
vec3 direction;
|
|
bool visible;
|
|
};
|
|
struct ReflectedLight {
|
|
vec3 directDiffuse;
|
|
vec3 directSpecular;
|
|
vec3 indirectDiffuse;
|
|
vec3 indirectSpecular;
|
|
};
|
|
struct GeometricContext {
|
|
vec3 position;
|
|
vec3 normal;
|
|
vec3 viewDir;
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal;
|
|
#endif
|
|
};
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
}
|
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
}
|
|
mat3 transposeMat3( const in mat3 m ) {
|
|
mat3 tmp;
|
|
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|
return tmp;
|
|
}
|
|
float linearToRelativeLuminance( const in vec3 color ) {
|
|
vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
|
|
return dot( weights, color.rgb );
|
|
}
|
|
bool isPerspectiveMatrix( mat4 m ) {
|
|
return m[ 2 ][ 3 ] == - 1.0;
|
|
}
|
|
vec2 equirectUv( in vec3 dir ) {
|
|
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|
return vec2( u, v );
|
|
}`,Jh=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
#define cubeUV_maxMipLevel 8.0
|
|
#define cubeUV_minMipLevel 4.0
|
|
#define cubeUV_maxTileSize 256.0
|
|
#define cubeUV_minTileSize 16.0
|
|
float getFace( vec3 direction ) {
|
|
vec3 absDirection = abs( direction );
|
|
float face = - 1.0;
|
|
if ( absDirection.x > absDirection.z ) {
|
|
if ( absDirection.x > absDirection.y )
|
|
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
} else {
|
|
if ( absDirection.z > absDirection.y )
|
|
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
}
|
|
return face;
|
|
}
|
|
vec2 getUV( vec3 direction, float face ) {
|
|
vec2 uv;
|
|
if ( face == 0.0 ) {
|
|
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 1.0 ) {
|
|
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
} else if ( face == 2.0 ) {
|
|
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
} else if ( face == 3.0 ) {
|
|
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 4.0 ) {
|
|
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
} else {
|
|
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
}
|
|
return 0.5 * ( uv + 1.0 );
|
|
}
|
|
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
float face = getFace( direction );
|
|
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
float faceSize = exp2( mipInt );
|
|
float texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );
|
|
vec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;
|
|
if ( face > 2.0 ) {
|
|
uv.y += faceSize;
|
|
face -= 3.0;
|
|
}
|
|
uv.x += face * faceSize;
|
|
if ( mipInt < cubeUV_maxMipLevel ) {
|
|
uv.y += 2.0 * cubeUV_maxTileSize;
|
|
}
|
|
uv.y += filterInt * 2.0 * cubeUV_minTileSize;
|
|
uv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );
|
|
uv *= texelSize;
|
|
return texture2D( envMap, uv ).rgb;
|
|
}
|
|
#define r0 1.0
|
|
#define v0 0.339
|
|
#define m0 - 2.0
|
|
#define r1 0.8
|
|
#define v1 0.276
|
|
#define m1 - 1.0
|
|
#define r4 0.4
|
|
#define v4 0.046
|
|
#define m4 2.0
|
|
#define r5 0.305
|
|
#define v5 0.016
|
|
#define m5 3.0
|
|
#define r6 0.21
|
|
#define v6 0.0038
|
|
#define m6 4.0
|
|
float roughnessToMip( float roughness ) {
|
|
float mip = 0.0;
|
|
if ( roughness >= r1 ) {
|
|
mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
|
|
} else if ( roughness >= r4 ) {
|
|
mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
|
|
} else if ( roughness >= r5 ) {
|
|
mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
|
|
} else if ( roughness >= r6 ) {
|
|
mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
|
|
} else {
|
|
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
return mip;
|
|
}
|
|
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
float mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );
|
|
float mipF = fract( mip );
|
|
float mipInt = floor( mip );
|
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
if ( mipF == 0.0 ) {
|
|
return vec4( color0, 1.0 );
|
|
} else {
|
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
}
|
|
}
|
|
#endif`,Zh=`vec3 transformedNormal = objectNormal;
|
|
#ifdef USE_INSTANCING
|
|
mat3 m = mat3( instanceMatrix );
|
|
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
|
|
transformedNormal = m * transformedNormal;
|
|
#endif
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|
#ifdef FLIP_SIDED
|
|
transformedNormal = - transformedNormal;
|
|
#endif
|
|
#ifdef USE_TANGENT
|
|
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
#ifdef FLIP_SIDED
|
|
transformedTangent = - transformedTangent;
|
|
#endif
|
|
#endif`,$h=`#ifdef USE_DISPLACEMENTMAP
|
|
uniform sampler2D displacementMap;
|
|
uniform float displacementScale;
|
|
uniform float displacementBias;
|
|
#endif`,Kh=`#ifdef USE_DISPLACEMENTMAP
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
|
|
#endif`,Qh=`#ifdef USE_EMISSIVEMAP
|
|
vec4 emissiveColor = texture2D( emissiveMap, vUv );
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
#endif`,eu=`#ifdef USE_EMISSIVEMAP
|
|
uniform sampler2D emissiveMap;
|
|
#endif`,tu="gl_FragColor = linearToOutputTexel( gl_FragColor );",nu=`vec4 LinearToLinear( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 LinearTosRGB( in vec4 value ) {
|
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
}`,iu=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vec3 cameraToFrag;
|
|
if ( isOrthographic ) {
|
|
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
#else
|
|
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
#endif
|
|
#else
|
|
vec3 reflectVec = vReflect;
|
|
#endif
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
|
|
#else
|
|
vec4 envColor = vec4( 0.0 );
|
|
#endif
|
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_MIX )
|
|
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
#endif
|
|
#endif`,ru=`#ifdef USE_ENVMAP
|
|
uniform float envMapIntensity;
|
|
uniform float flipEnvMap;
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#else
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
|
|
#endif`,su=`#ifdef USE_ENVMAP
|
|
uniform float reflectivity;
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
varying vec3 vWorldPosition;
|
|
uniform float refractionRatio;
|
|
#else
|
|
varying vec3 vReflect;
|
|
#endif
|
|
#endif`,ou=`#ifdef USE_ENVMAP
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
|
|
varying vec3 vWorldPosition;
|
|
#else
|
|
varying vec3 vReflect;
|
|
uniform float refractionRatio;
|
|
#endif
|
|
#endif`,au=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vWorldPosition = worldPosition.xyz;
|
|
#else
|
|
vec3 cameraToVertex;
|
|
if ( isOrthographic ) {
|
|
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vReflect = reflect( cameraToVertex, worldNormal );
|
|
#else
|
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
#endif
|
|
#endif
|
|
#endif`,lu=`#ifdef USE_FOG
|
|
vFogDepth = - mvPosition.z;
|
|
#endif`,cu=`#ifdef USE_FOG
|
|
varying float vFogDepth;
|
|
#endif`,hu=`#ifdef USE_FOG
|
|
#ifdef FOG_EXP2
|
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
#else
|
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
#endif
|
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
#endif`,uu=`#ifdef USE_FOG
|
|
uniform vec3 fogColor;
|
|
varying float vFogDepth;
|
|
#ifdef FOG_EXP2
|
|
uniform float fogDensity;
|
|
#else
|
|
uniform float fogNear;
|
|
uniform float fogFar;
|
|
#endif
|
|
#endif`,du=`#ifdef USE_GRADIENTMAP
|
|
uniform sampler2D gradientMap;
|
|
#endif
|
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
float dotNL = dot( normal, lightDirection );
|
|
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|
#ifdef USE_GRADIENTMAP
|
|
return vec3( texture2D( gradientMap, coord ).r );
|
|
#else
|
|
return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
|
|
#endif
|
|
}`,fu=`#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
|
lightMapIrradiance *= PI;
|
|
#endif
|
|
reflectedLight.indirectDiffuse += lightMapIrradiance;
|
|
#endif`,pu=`#ifdef USE_LIGHTMAP
|
|
uniform sampler2D lightMap;
|
|
uniform float lightMapIntensity;
|
|
#endif`,mu=`vec3 diffuse = vec3( 1.0 );
|
|
GeometricContext geometry;
|
|
geometry.position = mvPosition.xyz;
|
|
geometry.normal = normalize( transformedNormal );
|
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
|
|
GeometricContext backGeometry;
|
|
backGeometry.position = geometry.position;
|
|
backGeometry.normal = -geometry.normal;
|
|
backGeometry.viewDir = geometry.viewDir;
|
|
vLightFront = vec3( 0.0 );
|
|
vIndirectFront = vec3( 0.0 );
|
|
#ifdef DOUBLE_SIDED
|
|
vLightBack = vec3( 0.0 );
|
|
vIndirectBack = vec3( 0.0 );
|
|
#endif
|
|
IncidentLight directLight;
|
|
float dotNL;
|
|
vec3 directLightColor_Diffuse;
|
|
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
|
|
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
#ifdef DOUBLE_SIDED
|
|
vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
|
|
vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
|
|
#endif
|
|
#if NUM_POINT_LIGHTS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
getPointLightInfo( pointLights[ i ], geometry, directLight );
|
|
dotNL = dot( geometry.normal, directLight.direction );
|
|
directLightColor_Diffuse = directLight.color;
|
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
|
#ifdef DOUBLE_SIDED
|
|
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
|
|
#endif
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_SPOT_LIGHTS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
getSpotLightInfo( spotLights[ i ], geometry, directLight );
|
|
dotNL = dot( geometry.normal, directLight.direction );
|
|
directLightColor_Diffuse = directLight.color;
|
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
|
#ifdef DOUBLE_SIDED
|
|
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
|
|
#endif
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_DIR_LIGHTS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
|
|
dotNL = dot( geometry.normal, directLight.direction );
|
|
directLightColor_Diffuse = directLight.color;
|
|
vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
|
|
#ifdef DOUBLE_SIDED
|
|
vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
|
|
#endif
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_HEMI_LIGHTS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
|
#ifdef DOUBLE_SIDED
|
|
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
|
|
#endif
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif`,gu=`uniform bool receiveShadow;
|
|
uniform vec3 ambientLightColor;
|
|
uniform vec3 lightProbe[ 9 ];
|
|
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
float x = normal.x, y = normal.y, z = normal.z;
|
|
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
return result;
|
|
}
|
|
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
return irradiance;
|
|
}
|
|
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
vec3 irradiance = ambientLightColor;
|
|
return irradiance;
|
|
}
|
|
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
#if defined ( PHYSICALLY_CORRECT_LIGHTS )
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
if ( cutoffDistance > 0.0 ) {
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
}
|
|
return distanceFalloff;
|
|
#else
|
|
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
|
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
|
}
|
|
return 1.0;
|
|
#endif
|
|
}
|
|
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
}
|
|
#if NUM_DIR_LIGHTS > 0
|
|
struct DirectionalLight {
|
|
vec3 direction;
|
|
vec3 color;
|
|
};
|
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
|
|
light.color = directionalLight.color;
|
|
light.direction = directionalLight.direction;
|
|
light.visible = true;
|
|
}
|
|
#endif
|
|
#if NUM_POINT_LIGHTS > 0
|
|
struct PointLight {
|
|
vec3 position;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
};
|
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
|
|
vec3 lVector = pointLight.position - geometry.position;
|
|
light.direction = normalize( lVector );
|
|
float lightDistance = length( lVector );
|
|
light.color = pointLight.color;
|
|
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
}
|
|
#endif
|
|
#if NUM_SPOT_LIGHTS > 0
|
|
struct SpotLight {
|
|
vec3 position;
|
|
vec3 direction;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
float coneCos;
|
|
float penumbraCos;
|
|
};
|
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
|
|
vec3 lVector = spotLight.position - geometry.position;
|
|
light.direction = normalize( lVector );
|
|
float angleCos = dot( light.direction, spotLight.direction );
|
|
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
if ( spotAttenuation > 0.0 ) {
|
|
float lightDistance = length( lVector );
|
|
light.color = spotLight.color * spotAttenuation;
|
|
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
} else {
|
|
light.color = vec3( 0.0 );
|
|
light.visible = false;
|
|
}
|
|
}
|
|
#endif
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
struct RectAreaLight {
|
|
vec3 color;
|
|
vec3 position;
|
|
vec3 halfWidth;
|
|
vec3 halfHeight;
|
|
};
|
|
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
#endif
|
|
#if NUM_HEMI_LIGHTS > 0
|
|
struct HemisphereLight {
|
|
vec3 direction;
|
|
vec3 skyColor;
|
|
vec3 groundColor;
|
|
};
|
|
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
float dotNL = dot( normal, hemiLight.direction );
|
|
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
return irradiance;
|
|
}
|
|
#endif`,xu=`#if defined( USE_ENVMAP )
|
|
#ifdef ENVMAP_MODE_REFRACTION
|
|
uniform float refractionRatio;
|
|
#endif
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
#if defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
|
|
return PI * envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
#if defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec3 reflectVec;
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
reflectVec = reflect( - viewDir, normal );
|
|
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
|
#else
|
|
reflectVec = refract( - viewDir, normal, refractionRatio );
|
|
#endif
|
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
|
|
return envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#endif`,_u=`ToonMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;`,vu=`varying vec3 vViewPosition;
|
|
struct ToonMaterial {
|
|
vec3 diffuseColor;
|
|
};
|
|
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Toon
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
|
|
#define Material_LightProbeLOD( material ) (0)`,yu=`BlinnPhongMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularColor = specular;
|
|
material.specularShininess = shininess;
|
|
material.specularStrength = specularStrength;`,Mu=`varying vec3 vViewPosition;
|
|
struct BlinnPhongMaterial {
|
|
vec3 diffuseColor;
|
|
vec3 specularColor;
|
|
float specularShininess;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
}
|
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
|
|
#define Material_LightProbeLOD( material ) (0)`,bu=`PhysicalMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
|
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
material.roughness = min( material.roughness, 1.0 );
|
|
#ifdef IOR
|
|
#ifdef SPECULAR
|
|
float specularIntensityFactor = specularIntensity;
|
|
vec3 specularColorFactor = specularColor;
|
|
#ifdef USE_SPECULARINTENSITYMAP
|
|
specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
|
|
#endif
|
|
#ifdef USE_SPECULARCOLORMAP
|
|
specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
|
|
#endif
|
|
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
#else
|
|
float specularIntensityFactor = 1.0;
|
|
vec3 specularColorFactor = vec3( 1.0 );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
#else
|
|
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
material.clearcoat = clearcoat;
|
|
material.clearcoatRoughness = clearcoatRoughness;
|
|
material.clearcoatF0 = vec3( 0.04 );
|
|
material.clearcoatF90 = 1.0;
|
|
#ifdef USE_CLEARCOATMAP
|
|
material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
|
|
#endif
|
|
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
material.clearcoatRoughness += geometryRoughness;
|
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
material.sheenColor = sheenColor;
|
|
#ifdef USE_SHEENCOLORMAP
|
|
material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
|
|
#endif
|
|
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
#ifdef USE_SHEENROUGHNESSMAP
|
|
material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
|
|
#endif
|
|
#endif`,wu=`struct PhysicalMaterial {
|
|
vec3 diffuseColor;
|
|
float roughness;
|
|
vec3 specularColor;
|
|
float specularF90;
|
|
#ifdef USE_CLEARCOAT
|
|
float clearcoat;
|
|
float clearcoatRoughness;
|
|
vec3 clearcoatF0;
|
|
float clearcoatF90;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
vec3 sheenColor;
|
|
float sheenRoughness;
|
|
#endif
|
|
};
|
|
vec3 clearcoatSpecular = vec3( 0.0 );
|
|
vec3 sheenSpecular = vec3( 0.0 );
|
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float r2 = roughness * roughness;
|
|
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
return saturate( DG * RECIPROCAL_PI );
|
|
}
|
|
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
vec4 r = roughness * c0 + c1;
|
|
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|
return fab;
|
|
}
|
|
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
return specularColor * fab.x + specularF90 * fab.y;
|
|
}
|
|
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 ) {
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
|
|
float Ess = fab.x + fab.y;
|
|
float Ems = 1.0 - Ess;
|
|
vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
singleScatter += FssEss;
|
|
multiScatter += Fms * Ems;
|
|
}
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 normal = geometry.normal;
|
|
vec3 viewDir = geometry.viewDir;
|
|
vec3 position = geometry.position;
|
|
vec3 lightPos = rectAreaLight.position;
|
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
vec3 lightColor = rectAreaLight.color;
|
|
float roughness = material.roughness;
|
|
vec3 rectCoords[ 4 ];
|
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
vec4 t1 = texture2D( ltc_1, uv );
|
|
vec4 t2 = texture2D( ltc_2, uv );
|
|
mat3 mInv = mat3(
|
|
vec3( t1.x, 0, t1.y ),
|
|
vec3( 0, 1, 0 ),
|
|
vec3( t1.z, 0, t1.w )
|
|
);
|
|
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
}
|
|
#endif
|
|
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
|
|
#endif
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
|
|
#endif
|
|
vec3 singleScattering = vec3( 0.0 );
|
|
vec3 multiScattering = vec3( 0.0 );
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
vec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );
|
|
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
}
|
|
#define RE_Direct RE_Direct_Physical
|
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
}`,Su=`
|
|
GeometricContext geometry;
|
|
geometry.position = - vViewPosition;
|
|
geometry.normal = normal;
|
|
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
#ifdef USE_CLEARCOAT
|
|
geometry.clearcoatNormal = clearcoatNormal;
|
|
#endif
|
|
IncidentLight directLight;
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
PointLight pointLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
pointLight = pointLights[ i ];
|
|
getPointLightInfo( pointLight, geometry, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
pointLightShadow = pointLightShadows[ i ];
|
|
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
SpotLight spotLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
spotLight = spotLights[ i ];
|
|
getSpotLightInfo( spotLight, geometry, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
DirectionalLight directionalLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
directionalLight = directionalLights[ i ];
|
|
getDirectionalLightInfo( directionalLight, geometry, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
RectAreaLight rectAreaLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
rectAreaLight = rectAreaLights[ i ];
|
|
RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if defined( RE_IndirectDiffuse )
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
vec3 radiance = vec3( 0.0 );
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
#endif`,Eu=`#if defined( RE_IndirectDiffuse )
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
#ifndef PHYSICALLY_CORRECT_LIGHTS
|
|
lightMapIrradiance *= PI;
|
|
#endif
|
|
irradiance += lightMapIrradiance;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
iblIrradiance += getIBLIrradiance( geometry.normal );
|
|
#endif
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
|
|
#endif
|
|
#endif`,Tu=`#if defined( RE_IndirectDiffuse )
|
|
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
|
|
#endif`,Au=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
#endif`,Cu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
uniform float logDepthBufFC;
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,Lu=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#else
|
|
uniform float logDepthBufFC;
|
|
#endif
|
|
#endif`,Ru=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
#else
|
|
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
|
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
|
gl_Position.z *= gl_Position.w;
|
|
}
|
|
#endif
|
|
#endif`,Pu=`#ifdef USE_MAP
|
|
vec4 sampledDiffuseColor = texture2D( map, vUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
|
|
#endif
|
|
diffuseColor *= sampledDiffuseColor;
|
|
#endif`,Du=`#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif`,Iu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
diffuseColor *= texture2D( map, uv );
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
#endif`,Fu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,Nu=`float metalnessFactor = metalness;
|
|
#ifdef USE_METALNESSMAP
|
|
vec4 texelMetalness = texture2D( metalnessMap, vUv );
|
|
metalnessFactor *= texelMetalness.b;
|
|
#endif`,Bu=`#ifdef USE_METALNESSMAP
|
|
uniform sampler2D metalnessMap;
|
|
#endif`,zu=`#ifdef USE_MORPHNORMALS
|
|
objectNormal *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];
|
|
}
|
|
#else
|
|
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
|
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
|
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
|
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
|
#endif
|
|
#endif`,Uu=`#ifdef USE_MORPHTARGETS
|
|
uniform float morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
uniform sampler2DArray morphTargetsTexture;
|
|
uniform vec2 morphTargetsTextureSize;
|
|
vec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {
|
|
float texelIndex = float( vertexIndex * stride + offset );
|
|
float y = floor( texelIndex / morphTargetsTextureSize.x );
|
|
float x = texelIndex - y * morphTargetsTextureSize.x;
|
|
vec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );
|
|
return texture( morphTargetsTexture, morphUV ).xyz;
|
|
}
|
|
#else
|
|
#ifndef USE_MORPHNORMALS
|
|
uniform float morphTargetInfluences[ 8 ];
|
|
#else
|
|
uniform float morphTargetInfluences[ 4 ];
|
|
#endif
|
|
#endif
|
|
#endif`,Ou=`#ifdef USE_MORPHTARGETS
|
|
transformed *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
#ifndef USE_MORPHNORMALS
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];
|
|
#else
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];
|
|
#endif
|
|
}
|
|
#else
|
|
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
|
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
|
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
|
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
|
#ifndef USE_MORPHNORMALS
|
|
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
|
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
|
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
|
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
|
#endif
|
|
#endif
|
|
#endif`,Hu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
#ifdef FLAT_SHADED
|
|
vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
|
|
vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
#else
|
|
vec3 normal = normalize( vNormal );
|
|
#ifdef DOUBLE_SIDED
|
|
normal = normal * faceDirection;
|
|
#endif
|
|
#ifdef USE_TANGENT
|
|
vec3 tangent = normalize( vTangent );
|
|
vec3 bitangent = normalize( vBitangent );
|
|
#ifdef DOUBLE_SIDED
|
|
tangent = tangent * faceDirection;
|
|
bitangent = bitangent * faceDirection;
|
|
#endif
|
|
#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
|
|
mat3 vTBN = mat3( tangent, bitangent, normal );
|
|
#endif
|
|
#endif
|
|
#endif
|
|
vec3 geometryNormal = normal;`,Vu=`#ifdef OBJECTSPACE_NORMALMAP
|
|
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
|
#ifdef FLIP_SIDED
|
|
normal = - normal;
|
|
#endif
|
|
#ifdef DOUBLE_SIDED
|
|
normal = normal * faceDirection;
|
|
#endif
|
|
normal = normalize( normalMatrix * normal );
|
|
#elif defined( TANGENTSPACE_NORMALMAP )
|
|
vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
|
|
mapN.xy *= normalScale;
|
|
#ifdef USE_TANGENT
|
|
normal = normalize( vTBN * mapN );
|
|
#else
|
|
normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
|
|
#endif
|
|
#elif defined( USE_BUMPMAP )
|
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
#endif`,Gu=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,ku=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,Wu=`#ifndef FLAT_SHADED
|
|
vNormal = normalize( transformedNormal );
|
|
#ifdef USE_TANGENT
|
|
vTangent = normalize( transformedTangent );
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
#endif
|
|
#endif`,qu=`#ifdef USE_NORMALMAP
|
|
uniform sampler2D normalMap;
|
|
uniform vec2 normalScale;
|
|
#endif
|
|
#ifdef OBJECTSPACE_NORMALMAP
|
|
uniform mat3 normalMatrix;
|
|
#endif
|
|
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
|
|
vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
|
|
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
|
|
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
|
|
vec2 st0 = dFdx( vUv.st );
|
|
vec2 st1 = dFdy( vUv.st );
|
|
vec3 N = surf_norm;
|
|
vec3 q1perp = cross( q1, N );
|
|
vec3 q0perp = cross( N, q0 );
|
|
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
float det = max( dot( T, T ), dot( B, B ) );
|
|
float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
|
|
return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
|
|
}
|
|
#endif`,Xu=`#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal = geometryNormal;
|
|
#endif`,ju=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
#ifdef USE_TANGENT
|
|
clearcoatNormal = normalize( vTBN * clearcoatMapN );
|
|
#else
|
|
clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
|
|
#endif
|
|
#endif`,Yu=`#ifdef USE_CLEARCOATMAP
|
|
uniform sampler2D clearcoatMap;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform sampler2D clearcoatRoughnessMap;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform sampler2D clearcoatNormalMap;
|
|
uniform vec2 clearcoatNormalScale;
|
|
#endif`,Ju=`#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= transmissionAlpha + 0.1;
|
|
#endif
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Zu=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
return normalize( normal ) * 0.5 + 0.5;
|
|
}
|
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
return 2.0 * rgb.xyz - 1.0;
|
|
}
|
|
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
|
|
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
|
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
|
const float ShiftRight8 = 1. / 256.;
|
|
vec4 packDepthToRGBA( const in float v ) {
|
|
vec4 r = vec4( fract( v * PackFactors ), v );
|
|
r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
|
|
}
|
|
float unpackRGBAToDepth( const in vec4 v ) {
|
|
return dot( v, UnpackFactors );
|
|
}
|
|
vec4 pack2HalfToRGBA( vec2 v ) {
|
|
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|
}
|
|
vec2 unpackRGBATo2Half( vec4 v ) {
|
|
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|
}
|
|
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( viewZ + near ) / ( near - far );
|
|
}
|
|
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
|
|
return linearClipZ * ( near - far ) - near;
|
|
}
|
|
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
}
|
|
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
|
|
return ( near * far ) / ( ( far - near ) * invClipZ - far );
|
|
}`,$u=`#ifdef PREMULTIPLIED_ALPHA
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
#endif`,Ku=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_INSTANCING
|
|
mvPosition = instanceMatrix * mvPosition;
|
|
#endif
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|
gl_Position = projectionMatrix * mvPosition;`,Qu=`#ifdef DITHERING
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
#endif`,ed=`#ifdef DITHERING
|
|
vec3 dithering( vec3 color ) {
|
|
float grid_position = rand( gl_FragCoord.xy );
|
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
return color + dither_shift_RGB;
|
|
}
|
|
#endif`,td=`float roughnessFactor = roughness;
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vec4 texelRoughness = texture2D( roughnessMap, vUv );
|
|
roughnessFactor *= texelRoughness.g;
|
|
#endif`,nd=`#ifdef USE_ROUGHNESSMAP
|
|
uniform sampler2D roughnessMap;
|
|
#endif`,id=`#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
struct SpotLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
|
}
|
|
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
}
|
|
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
|
float occlusion = 1.0;
|
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
float hard_shadow = step( compare , distribution.x );
|
|
if (hard_shadow != 1.0 ) {
|
|
float distance = compare - distribution.x ;
|
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
}
|
|
return occlusion;
|
|
}
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
float shadow = 1.0;
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|
shadowCoord.z += shadowBias;
|
|
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
|
|
bool inFrustum = all( inFrustumVec );
|
|
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
|
|
bool frustumTest = all( frustumTestVec );
|
|
if ( frustumTest ) {
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx0 = - texelSize.x * shadowRadius;
|
|
float dy0 = - texelSize.y * shadowRadius;
|
|
float dx1 = + texelSize.x * shadowRadius;
|
|
float dy1 = + texelSize.y * shadowRadius;
|
|
float dx2 = dx0 / 2.0;
|
|
float dy2 = dy0 / 2.0;
|
|
float dx3 = dx1 / 2.0;
|
|
float dy3 = dy1 / 2.0;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
) * ( 1.0 / 17.0 );
|
|
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx = texelSize.x;
|
|
float dy = texelSize.y;
|
|
vec2 uv = shadowCoord.xy;
|
|
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
uv -= f * texelSize;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
f.x ),
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.x ),
|
|
f.y )
|
|
) * ( 1.0 / 9.0 );
|
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#else
|
|
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#endif
|
|
}
|
|
return shadow;
|
|
}
|
|
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
vec3 absV = abs( v );
|
|
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
absV *= scaleToCube;
|
|
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
vec2 planar = v.xy;
|
|
float almostATexel = 1.5 * texelSizeY;
|
|
float almostOne = 1.0 - almostATexel;
|
|
if ( absV.z >= almostOne ) {
|
|
if ( v.z > 0.0 )
|
|
planar.x = 4.0 - v.x;
|
|
} else if ( absV.x >= almostOne ) {
|
|
float signX = sign( v.x );
|
|
planar.x = v.z * signX + 2.0 * signX;
|
|
} else if ( absV.y >= almostOne ) {
|
|
float signY = sign( v.y );
|
|
planar.x = v.x + 2.0 * signY + 2.0;
|
|
planar.y = v.z * signY - 2.0;
|
|
}
|
|
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
}
|
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
return (
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
) * ( 1.0 / 9.0 );
|
|
#else
|
|
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
#endif
|
|
}
|
|
#endif`,rd=`#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
struct SpotLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#endif`,sd=`#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
|
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
vec4 shadowWorldPosition;
|
|
#endif
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
|
|
vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif`,od=`float getShadowMask() {
|
|
float shadow = 1.0;
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
directionalLight = directionalLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
spotLight = spotLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
pointLight = pointLightShadows[ i ];
|
|
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
return shadow;
|
|
}`,ad=`#ifdef USE_SKINNING
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
#endif`,ld=`#ifdef USE_SKINNING
|
|
uniform mat4 bindMatrix;
|
|
uniform mat4 bindMatrixInverse;
|
|
#ifdef BONE_TEXTURE
|
|
uniform highp sampler2D boneTexture;
|
|
uniform int boneTextureSize;
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
float j = i * 4.0;
|
|
float x = mod( j, float( boneTextureSize ) );
|
|
float y = floor( j / float( boneTextureSize ) );
|
|
float dx = 1.0 / float( boneTextureSize );
|
|
float dy = 1.0 / float( boneTextureSize );
|
|
y = dy * ( y + 0.5 );
|
|
vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
|
|
vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
|
|
vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
|
|
vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
|
|
mat4 bone = mat4( v1, v2, v3, v4 );
|
|
return bone;
|
|
}
|
|
#else
|
|
uniform mat4 boneMatrices[ MAX_BONES ];
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
mat4 bone = boneMatrices[ int(i) ];
|
|
return bone;
|
|
}
|
|
#endif
|
|
#endif`,cd=`#ifdef USE_SKINNING
|
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
vec4 skinned = vec4( 0.0 );
|
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
skinned += boneMatY * skinVertex * skinWeight.y;
|
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
#endif`,hd=`#ifdef USE_SKINNING
|
|
mat4 skinMatrix = mat4( 0.0 );
|
|
skinMatrix += skinWeight.x * boneMatX;
|
|
skinMatrix += skinWeight.y * boneMatY;
|
|
skinMatrix += skinWeight.z * boneMatZ;
|
|
skinMatrix += skinWeight.w * boneMatW;
|
|
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|
#ifdef USE_TANGENT
|
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
#endif
|
|
#endif`,ud=`float specularStrength;
|
|
#ifdef USE_SPECULARMAP
|
|
vec4 texelSpecular = texture2D( specularMap, vUv );
|
|
specularStrength = texelSpecular.r;
|
|
#else
|
|
specularStrength = 1.0;
|
|
#endif`,dd=`#ifdef USE_SPECULARMAP
|
|
uniform sampler2D specularMap;
|
|
#endif`,fd=`#if defined( TONE_MAPPING )
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
#endif`,pd=`#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
uniform float toneMappingExposure;
|
|
vec3 LinearToneMapping( vec3 color ) {
|
|
return toneMappingExposure * color;
|
|
}
|
|
vec3 ReinhardToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
}
|
|
vec3 OptimizedCineonToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
color = max( vec3( 0.0 ), color - 0.004 );
|
|
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|
}
|
|
vec3 RRTAndODTFit( vec3 v ) {
|
|
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|
return a / b;
|
|
}
|
|
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
const mat3 ACESInputMat = mat3(
|
|
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|
vec3( 0.04823, 0.01566, 0.83777 )
|
|
);
|
|
const mat3 ACESOutputMat = mat3(
|
|
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|
vec3( -0.07367, -0.00605, 1.07602 )
|
|
);
|
|
color *= toneMappingExposure / 0.6;
|
|
color = ACESInputMat * color;
|
|
color = RRTAndODTFit( color );
|
|
color = ACESOutputMat * color;
|
|
return saturate( color );
|
|
}
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,md=`#ifdef USE_TRANSMISSION
|
|
float transmissionAlpha = 1.0;
|
|
float transmissionFactor = transmission;
|
|
float thicknessFactor = thickness;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
transmissionFactor *= texture2D( transmissionMap, vUv ).r;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
thicknessFactor *= texture2D( thicknessMap, vUv ).g;
|
|
#endif
|
|
vec3 pos = vWorldPosition;
|
|
vec3 v = normalize( cameraPosition - pos );
|
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 transmission = getIBLVolumeRefraction(
|
|
n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,
|
|
attenuationColor, attenuationDistance );
|
|
totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );
|
|
transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );
|
|
#endif`,gd=`#ifdef USE_TRANSMISSION
|
|
uniform float transmission;
|
|
uniform float thickness;
|
|
uniform float attenuationDistance;
|
|
uniform vec3 attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform sampler2D transmissionMap;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform sampler2D thicknessMap;
|
|
#endif
|
|
uniform vec2 transmissionSamplerSize;
|
|
uniform sampler2D transmissionSamplerMap;
|
|
uniform mat4 modelMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
varying vec3 vWorldPosition;
|
|
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
vec3 modelScale;
|
|
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
return normalize( refractionVector ) * thickness * modelScale;
|
|
}
|
|
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
}
|
|
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
#ifdef TEXTURE_LOD_EXT
|
|
return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
|
|
#else
|
|
return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
|
|
#endif
|
|
}
|
|
vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
if ( attenuationDistance == 0.0 ) {
|
|
return radiance;
|
|
} else {
|
|
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance;
|
|
}
|
|
}
|
|
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
refractionCoords += 1.0;
|
|
refractionCoords /= 2.0;
|
|
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
|
|
}
|
|
#endif`,xd=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
|
|
varying vec2 vUv;
|
|
#endif`,_d=`#ifdef USE_UV
|
|
#ifdef UVS_VERTEX_ONLY
|
|
vec2 vUv;
|
|
#else
|
|
varying vec2 vUv;
|
|
#endif
|
|
uniform mat3 uvTransform;
|
|
#endif`,vd=`#ifdef USE_UV
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
#endif`,yd=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
|
varying vec2 vUv2;
|
|
#endif`,Md=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
|
attribute vec2 uv2;
|
|
varying vec2 vUv2;
|
|
uniform mat3 uv2Transform;
|
|
#endif`,bd=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
|
|
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
|
|
#endif`,wd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )
|
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_INSTANCING
|
|
worldPosition = instanceMatrix * worldPosition;
|
|
#endif
|
|
worldPosition = modelMatrix * worldPosition;
|
|
#endif`;const Sd=`varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
void main() {
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
}`,Ed=`uniform sampler2D t2D;
|
|
varying vec2 vUv;
|
|
void main() {
|
|
gl_FragColor = texture2D( t2D, vUv );
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
}`,Td=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,Ad=`#include <envmap_common_pars_fragment>
|
|
uniform float opacity;
|
|
varying vec3 vWorldDirection;
|
|
#include <cube_uv_reflection_fragment>
|
|
void main() {
|
|
vec3 vReflect = vWorldDirection;
|
|
#include <envmap_fragment>
|
|
gl_FragColor = envColor;
|
|
gl_FragColor.a *= opacity;
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
}`,Cd=`#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,Ld=`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
|
#if DEPTH_PACKING == 3200
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
#elif DEPTH_PACKING == 3201
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
#endif
|
|
}`,Rd=`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,Pd=`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = packDepthToRGBA( dist );
|
|
}`,Dd=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,Id=`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
}`,Fd=`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <color_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,Nd=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,Bd=`#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <uv2_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <uv2_vertex>
|
|
#include <color_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,zd=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <uv2_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <specularmap_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel= texture2D( lightMap, vUv2 );
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
#endif
|
|
#include <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Ud=`#define LAMBERT
|
|
varying vec3 vLightFront;
|
|
varying vec3 vIndirectFront;
|
|
#ifdef DOUBLE_SIDED
|
|
varying vec3 vLightBack;
|
|
varying vec3 vIndirectBack;
|
|
#endif
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <uv2_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <uv2_vertex>
|
|
#include <color_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <lights_lambert_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Od=`uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
varying vec3 vLightFront;
|
|
varying vec3 vIndirectFront;
|
|
#ifdef DOUBLE_SIDED
|
|
varying vec3 vLightBack;
|
|
varying vec3 vIndirectBack;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <uv2_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <fog_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <emissivemap_fragment>
|
|
#ifdef DOUBLE_SIDED
|
|
reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vIndirectFront;
|
|
#endif
|
|
#include <lightmap_fragment>
|
|
reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );
|
|
#ifdef DOUBLE_SIDED
|
|
reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
|
|
#else
|
|
reflectedLight.directDiffuse = vLightFront;
|
|
#endif
|
|
reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Hd=`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,Vd=`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
vec3 viewDir = normalize( vViewPosition );
|
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
vec3 y = cross( viewDir, x );
|
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
#ifdef USE_MATCAP
|
|
vec4 matcapColor = texture2D( matcap, uv );
|
|
#else
|
|
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
#endif
|
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Gd=`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,kd=`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,Wd=`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <uv2_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <uv2_vertex>
|
|
#include <color_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,qd=`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <uv2_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Xd=`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <uv2_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <uv2_vertex>
|
|
#include <color_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,jd=`#define STANDARD
|
|
#ifdef PHYSICAL
|
|
#define IOR
|
|
#define SPECULAR
|
|
#endif
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float roughness;
|
|
uniform float metalness;
|
|
uniform float opacity;
|
|
#ifdef IOR
|
|
uniform float ior;
|
|
#endif
|
|
#ifdef SPECULAR
|
|
uniform float specularIntensity;
|
|
uniform vec3 specularColor;
|
|
#ifdef USE_SPECULARINTENSITYMAP
|
|
uniform sampler2D specularIntensityMap;
|
|
#endif
|
|
#ifdef USE_SPECULARCOLORMAP
|
|
uniform sampler2D specularColorMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
uniform float clearcoat;
|
|
uniform float clearcoatRoughness;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
uniform vec3 sheenColor;
|
|
uniform float sheenRoughness;
|
|
#ifdef USE_SHEENCOLORMAP
|
|
uniform sampler2D sheenColorMap;
|
|
#endif
|
|
#ifdef USE_SHEENROUGHNESSMAP
|
|
uniform sampler2D sheenRoughnessMap;
|
|
#endif
|
|
#endif
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <uv2_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
|
|
#endif
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Yd=`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <uv2_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <uv2_vertex>
|
|
#include <color_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Jd=`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <uv2_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Zd=`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <color_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,$d=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,Kd=`#include <common>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Qd=`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
}`,ef=`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
vec2 scale;
|
|
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
#ifndef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
#endif
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
vec2 rotatedPosition;
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
mvPosition.xy += rotatedPosition;
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,tf=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <output_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <encodings_fragment>
|
|
#include <fog_fragment>
|
|
}`,Pe={alphamap_fragment:Rh,alphamap_pars_fragment:Ph,alphatest_fragment:Dh,alphatest_pars_fragment:Ih,aomap_fragment:Fh,aomap_pars_fragment:Nh,begin_vertex:Bh,beginnormal_vertex:zh,bsdfs:Uh,bumpmap_pars_fragment:Oh,clipping_planes_fragment:Hh,clipping_planes_pars_fragment:Vh,clipping_planes_pars_vertex:Gh,clipping_planes_vertex:kh,color_fragment:Wh,color_pars_fragment:qh,color_pars_vertex:Xh,color_vertex:jh,common:Yh,cube_uv_reflection_fragment:Jh,defaultnormal_vertex:Zh,displacementmap_pars_vertex:$h,displacementmap_vertex:Kh,emissivemap_fragment:Qh,emissivemap_pars_fragment:eu,encodings_fragment:tu,encodings_pars_fragment:nu,envmap_fragment:iu,envmap_common_pars_fragment:ru,envmap_pars_fragment:su,envmap_pars_vertex:ou,envmap_physical_pars_fragment:xu,envmap_vertex:au,fog_vertex:lu,fog_pars_vertex:cu,fog_fragment:hu,fog_pars_fragment:uu,gradientmap_pars_fragment:du,lightmap_fragment:fu,lightmap_pars_fragment:pu,lights_lambert_vertex:mu,lights_pars_begin:gu,lights_toon_fragment:_u,lights_toon_pars_fragment:vu,lights_phong_fragment:yu,lights_phong_pars_fragment:Mu,lights_physical_fragment:bu,lights_physical_pars_fragment:wu,lights_fragment_begin:Su,lights_fragment_maps:Eu,lights_fragment_end:Tu,logdepthbuf_fragment:Au,logdepthbuf_pars_fragment:Cu,logdepthbuf_pars_vertex:Lu,logdepthbuf_vertex:Ru,map_fragment:Pu,map_pars_fragment:Du,map_particle_fragment:Iu,map_particle_pars_fragment:Fu,metalnessmap_fragment:Nu,metalnessmap_pars_fragment:Bu,morphnormal_vertex:zu,morphtarget_pars_vertex:Uu,morphtarget_vertex:Ou,normal_fragment_begin:Hu,normal_fragment_maps:Vu,normal_pars_fragment:Gu,normal_pars_vertex:ku,normal_vertex:Wu,normalmap_pars_fragment:qu,clearcoat_normal_fragment_begin:Xu,clearcoat_normal_fragment_maps:ju,clearcoat_pars_fragment:Yu,output_fragment:Ju,packing:Zu,premultiplied_alpha_fragment:$u,project_vertex:Ku,dithering_fragment:Qu,dithering_pars_fragment:ed,roughnessmap_fragment:td,roughnessmap_pars_fragment:nd,shadowmap_pars_fragment:id,shadowmap_pars_vertex:rd,shadowmap_vertex:sd,shadowmask_pars_fragment:od,skinbase_vertex:ad,skinning_pars_vertex:ld,skinning_vertex:cd,skinnormal_vertex:hd,specularmap_fragment:ud,specularmap_pars_fragment:dd,tonemapping_fragment:fd,tonemapping_pars_fragment:pd,transmission_fragment:md,transmission_pars_fragment:gd,uv_pars_fragment:xd,uv_pars_vertex:_d,uv_vertex:vd,uv2_pars_fragment:yd,uv2_pars_vertex:Md,uv2_vertex:bd,worldpos_vertex:wd,background_vert:Sd,background_frag:Ed,cube_vert:Td,cube_frag:Ad,depth_vert:Cd,depth_frag:Ld,distanceRGBA_vert:Rd,distanceRGBA_frag:Pd,equirect_vert:Dd,equirect_frag:Id,linedashed_vert:Fd,linedashed_frag:Nd,meshbasic_vert:Bd,meshbasic_frag:zd,meshlambert_vert:Ud,meshlambert_frag:Od,meshmatcap_vert:Hd,meshmatcap_frag:Vd,meshnormal_vert:Gd,meshnormal_frag:kd,meshphong_vert:Wd,meshphong_frag:qd,meshphysical_vert:Xd,meshphysical_frag:jd,meshtoon_vert:Yd,meshtoon_frag:Jd,points_vert:Zd,points_frag:$d,shadow_vert:Kd,shadow_frag:Qd,sprite_vert:ef,sprite_frag:tf},ee={common:{diffuse:{value:new me(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new dt},uv2Transform:{value:new dt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new me(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new me(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new dt}},sprite:{diffuse:{value:new me(16777215)},opacity:{value:1},center:{value:new Z(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new dt}}},Ot={basic:{uniforms:pt([ee.common,ee.specularmap,ee.envmap,ee.aomap,ee.lightmap,ee.fog]),vertexShader:Pe.meshbasic_vert,fragmentShader:Pe.meshbasic_frag},lambert:{uniforms:pt([ee.common,ee.specularmap,ee.envmap,ee.aomap,ee.lightmap,ee.emissivemap,ee.fog,ee.lights,{emissive:{value:new me(0)}}]),vertexShader:Pe.meshlambert_vert,fragmentShader:Pe.meshlambert_frag},phong:{uniforms:pt([ee.common,ee.specularmap,ee.envmap,ee.aomap,ee.lightmap,ee.emissivemap,ee.bumpmap,ee.normalmap,ee.displacementmap,ee.fog,ee.lights,{emissive:{value:new me(0)},specular:{value:new me(1118481)},shininess:{value:30}}]),vertexShader:Pe.meshphong_vert,fragmentShader:Pe.meshphong_frag},standard:{uniforms:pt([ee.common,ee.envmap,ee.aomap,ee.lightmap,ee.emissivemap,ee.bumpmap,ee.normalmap,ee.displacementmap,ee.roughnessmap,ee.metalnessmap,ee.fog,ee.lights,{emissive:{value:new me(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Pe.meshphysical_vert,fragmentShader:Pe.meshphysical_frag},toon:{uniforms:pt([ee.common,ee.aomap,ee.lightmap,ee.emissivemap,ee.bumpmap,ee.normalmap,ee.displacementmap,ee.gradientmap,ee.fog,ee.lights,{emissive:{value:new me(0)}}]),vertexShader:Pe.meshtoon_vert,fragmentShader:Pe.meshtoon_frag},matcap:{uniforms:pt([ee.common,ee.bumpmap,ee.normalmap,ee.displacementmap,ee.fog,{matcap:{value:null}}]),vertexShader:Pe.meshmatcap_vert,fragmentShader:Pe.meshmatcap_frag},points:{uniforms:pt([ee.points,ee.fog]),vertexShader:Pe.points_vert,fragmentShader:Pe.points_frag},dashed:{uniforms:pt([ee.common,ee.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Pe.linedashed_vert,fragmentShader:Pe.linedashed_frag},depth:{uniforms:pt([ee.common,ee.displacementmap]),vertexShader:Pe.depth_vert,fragmentShader:Pe.depth_frag},normal:{uniforms:pt([ee.common,ee.bumpmap,ee.normalmap,ee.displacementmap,{opacity:{value:1}}]),vertexShader:Pe.meshnormal_vert,fragmentShader:Pe.meshnormal_frag},sprite:{uniforms:pt([ee.sprite,ee.fog]),vertexShader:Pe.sprite_vert,fragmentShader:Pe.sprite_frag},background:{uniforms:{uvTransform:{value:new dt},t2D:{value:null}},vertexShader:Pe.background_vert,fragmentShader:Pe.background_frag},cube:{uniforms:pt([ee.envmap,{opacity:{value:1}}]),vertexShader:Pe.cube_vert,fragmentShader:Pe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Pe.equirect_vert,fragmentShader:Pe.equirect_frag},distanceRGBA:{uniforms:pt([ee.common,ee.displacementmap,{referencePosition:{value:new w},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Pe.distanceRGBA_vert,fragmentShader:Pe.distanceRGBA_frag},shadow:{uniforms:pt([ee.lights,ee.fog,{color:{value:new me(0)},opacity:{value:1}}]),vertexShader:Pe.shadow_vert,fragmentShader:Pe.shadow_frag}};Ot.physical={uniforms:pt([Ot.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Z(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new me(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Z},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new me(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new me(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Pe.meshphysical_vert,fragmentShader:Pe.meshphysical_frag};function nf(s,e,t,n,i,r){const o=new me(0);let a=i===!0?0:1,c,l,h=null,u=0,d=null;function p(x,v){let m=!1,f=v.isScene===!0?v.background:null;f&&f.isTexture&&(f=e.get(f));const T=s.xr,y=T.getSession&&T.getSession();y&&y.environmentBlendMode==="additive"&&(f=null),f===null?g(o,a):f&&f.isColor&&(g(f,1),m=!0),(s.autoClear||m)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),f&&(f.isCubeTexture||f.mapping===Br)?(l===void 0&&(l=new st(new ki(1,1,1),new An({name:"BackgroundCubeMaterial",uniforms:ai(Ot.cube.uniforms),vertexShader:Ot.cube.vertexShader,fragmentShader:Ot.cube.fragmentShader,side:it,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(E,A,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=f,l.material.uniforms.flipEnvMap.value=f.isCubeTexture&&f.isRenderTargetTexture===!1?-1:1,(h!==f||u!==f.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=f,u=f.version,d=s.toneMapping),x.unshift(l,l.geometry,l.material,0,0,null)):f&&f.isTexture&&(c===void 0&&(c=new st(new no(2,2),new An({name:"BackgroundMaterial",uniforms:ai(Ot.background.uniforms),vertexShader:Ot.background.vertexShader,fragmentShader:Ot.background.fragmentShader,side:Di,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=f,f.matrixAutoUpdate===!0&&f.updateMatrix(),c.material.uniforms.uvTransform.value.copy(f.matrix),(h!==f||u!==f.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,h=f,u=f.version,d=s.toneMapping),x.unshift(c,c.geometry,c.material,0,0,null))}function g(x,v){t.buffers.color.setClear(x.r,x.g,x.b,v,r)}return{getClearColor:function(){return o},setClearColor:function(x,v=1){o.set(x),a=v,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(x){a=x,g(o,a)},render:p}}function rf(s,e,t,n){const i=s.getParameter(34921),r=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||r!==null,a={},c=x(null);let l=c;function h(P,B,F,I,H){let J=!1;if(o){const ce=g(I,F,B);l!==ce&&(l=ce,d(l.object)),J=v(I,H),J&&m(I,H)}else{const ce=B.wireframe===!0;(l.geometry!==I.id||l.program!==F.id||l.wireframe!==ce)&&(l.geometry=I.id,l.program=F.id,l.wireframe=ce,J=!0)}P.isInstancedMesh===!0&&(J=!0),H!==null&&t.update(H,34963),J&&(L(P,B,F,I),H!==null&&s.bindBuffer(34963,t.get(H).buffer))}function u(){return n.isWebGL2?s.createVertexArray():r.createVertexArrayOES()}function d(P){return n.isWebGL2?s.bindVertexArray(P):r.bindVertexArrayOES(P)}function p(P){return n.isWebGL2?s.deleteVertexArray(P):r.deleteVertexArrayOES(P)}function g(P,B,F){const I=F.wireframe===!0;let H=a[P.id];H===void 0&&(H={},a[P.id]=H);let J=H[B.id];J===void 0&&(J={},H[B.id]=J);let ce=J[I];return ce===void 0&&(ce=x(u()),J[I]=ce),ce}function x(P){const B=[],F=[],I=[];for(let H=0;H<i;H++)B[H]=0,F[H]=0,I[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:B,enabledAttributes:F,attributeDivisors:I,object:P,attributes:{},index:null}}function v(P,B){const F=l.attributes,I=P.attributes;let H=0;for(const J in I){const ce=F[J],U=I[J];if(ce===void 0||ce.attribute!==U||ce.data!==U.data)return!0;H++}return l.attributesNum!==H||l.index!==B}function m(P,B){const F={},I=P.attributes;let H=0;for(const J in I){const ce=I[J],U={};U.attribute=ce,ce.data&&(U.data=ce.data),F[J]=U,H++}l.attributes=F,l.attributesNum=H,l.index=B}function f(){const P=l.newAttributes;for(let B=0,F=P.length;B<F;B++)P[B]=0}function T(P){y(P,0)}function y(P,B){const F=l.newAttributes,I=l.enabledAttributes,H=l.attributeDivisors;F[P]=1,I[P]===0&&(s.enableVertexAttribArray(P),I[P]=1),H[P]!==B&&((n.isWebGL2?s:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](P,B),H[P]=B)}function E(){const P=l.newAttributes,B=l.enabledAttributes;for(let F=0,I=B.length;F<I;F++)B[F]!==P[F]&&(s.disableVertexAttribArray(F),B[F]=0)}function A(P,B,F,I,H,J){n.isWebGL2===!0&&(F===5124||F===5125)?s.vertexAttribIPointer(P,B,F,H,J):s.vertexAttribPointer(P,B,F,I,H,J)}function L(P,B,F,I){if(n.isWebGL2===!1&&(P.isInstancedMesh||I.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;f();const H=I.attributes,J=F.getAttributes(),ce=B.defaultAttributeValues;for(const U in J){const X=J[U];if(X.location>=0){let ie=H[U];if(ie===void 0&&(U==="instanceMatrix"&&P.instanceMatrix&&(ie=P.instanceMatrix),U==="instanceColor"&&P.instanceColor&&(ie=P.instanceColor)),ie!==void 0){const ue=ie.normalized,ge=ie.itemSize,O=t.get(ie);if(O===void 0)continue;const Be=O.buffer,fe=O.type,be=O.bytesPerElement;if(ie.isInterleavedBufferAttribute){const ae=ie.data,Ce=ae.stride,we=ie.offset;if(ae&&ae.isInstancedInterleavedBuffer){for(let k=0;k<X.locationSize;k++)y(X.location+k,ae.meshPerAttribute);P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let k=0;k<X.locationSize;k++)T(X.location+k);s.bindBuffer(34962,Be);for(let k=0;k<X.locationSize;k++)A(X.location+k,ge/X.locationSize,fe,ue,Ce*be,(we+ge/X.locationSize*k)*be)}else{if(ie.isInstancedBufferAttribute){for(let ae=0;ae<X.locationSize;ae++)y(X.location+ae,ie.meshPerAttribute);P.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let ae=0;ae<X.locationSize;ae++)T(X.location+ae);s.bindBuffer(34962,Be);for(let ae=0;ae<X.locationSize;ae++)A(X.location+ae,ge/X.locationSize,fe,ue,ge*be,ge/X.locationSize*ae*be)}}else if(ce!==void 0){const ue=ce[U];if(ue!==void 0)switch(ue.length){case 2:s.vertexAttrib2fv(X.location,ue);break;case 3:s.vertexAttrib3fv(X.location,ue);break;case 4:s.vertexAttrib4fv(X.location,ue);break;default:s.vertexAttrib1fv(X.location,ue)}}}}E()}function j(){_();for(const P in a){const B=a[P];for(const F in B){const I=B[F];for(const H in I)p(I[H].object),delete I[H];delete B[F]}delete a[P]}}function te(P){if(a[P.id]===void 0)return;const B=a[P.id];for(const F in B){const I=B[F];for(const H in I)p(I[H].object),delete I[H];delete B[F]}delete a[P.id]}function Y(P){for(const B in a){const F=a[B];if(F[P.id]===void 0)continue;const I=F[P.id];for(const H in I)p(I[H].object),delete I[H];delete F[P.id]}}function _(){R(),l!==c&&(l=c,d(l.object))}function R(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:_,resetDefaultState:R,dispose:j,releaseStatesOfGeometry:te,releaseStatesOfProgram:Y,initAttributes:f,enableAttribute:T,disableUnusedAttributes:E}}function sf(s,e,t,n){const i=n.isWebGL2;let r;function o(l){r=l}function a(l,h){s.drawArrays(r,l,h),t.update(h,r,1)}function c(l,h,u){if(u===0)return;let d,p;if(i)d=s,p="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),p="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[p](r,l,h,u),t.update(h,r,u)}this.setMode=o,this.render=a,this.renderInstances=c}function of(s,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const L=e.get("EXT_texture_filter_anisotropic");n=s.getParameter(L.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(L){if(L==="highp"){if(s.getShaderPrecisionFormat(35633,36338).precision>0&&s.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";L="mediump"}return L==="mediump"&&s.getShaderPrecisionFormat(35633,36337).precision>0&&s.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext!="undefined"&&s instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext!="undefined"&&s instanceof WebGL2ComputeRenderingContext;let a=t.precision!==void 0?t.precision:"highp";const c=r(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);const l=o||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=s.getParameter(34930),d=s.getParameter(35660),p=s.getParameter(3379),g=s.getParameter(34076),x=s.getParameter(34921),v=s.getParameter(36347),m=s.getParameter(36348),f=s.getParameter(36349),T=d>0,y=o||e.has("OES_texture_float"),E=T&&y,A=o?s.getParameter(36183):0;return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:r,precision:a,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:d,maxTextureSize:p,maxCubemapSize:g,maxAttributes:x,maxVertexUniforms:v,maxVaryings:m,maxFragmentUniforms:f,vertexTextures:T,floatFragmentTextures:y,floatVertexTextures:E,maxSamples:A}}function af(s){const e=this;let t=null,n=0,i=!1,r=!1;const o=new $t,a=new dt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d,p){const g=u.length!==0||d||n!==0||i;return i=d,t=h(u,p,0),n=u.length,g},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1,l()},this.setState=function(u,d,p){const g=u.clippingPlanes,x=u.clipIntersection,v=u.clipShadows,m=s.get(u);if(!i||g===null||g.length===0||r&&!v)r?h(null):l();else{const f=r?0:n,T=f*4;let y=m.clippingState||null;c.value=y,y=h(g,d,T,p);for(let E=0;E!==T;++E)y[E]=t[E];m.clippingState=y,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=f}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,p,g){const x=u!==null?u.length:0;let v=null;if(x!==0){if(v=c.value,g!==!0||v===null){const m=p+x*4,f=d.matrixWorldInverse;a.getNormalMatrix(f),(v===null||v.length<m)&&(v=new Float32Array(m));for(let T=0,y=p;T!==x;++T,y+=4)o.copy(u[T]).applyMatrix4(f,a),o.normal.toArray(v,y),v[y+3]=o.constant}c.value=v,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,v}}function lf(s){let e=new WeakMap;function t(o,a){return a===Ns?o.mapping=Vi:a===Bs&&(o.mapping=Gi),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){const a=o.mapping;if(a===Ns||a===Bs)if(e.has(o)){const c=e.get(o).texture;return t(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new pl(c.height/2);return l.fromEquirectangularTexture(s,o),e.set(o,l),o.addEventListener("dispose",i),t(l.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}class io extends eo{constructor(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}io.prototype.isOrthographicCamera=!0;class Hr extends An{constructor(e){super(e),this.type="RawShaderMaterial"}}Hr.prototype.isRawShaderMaterial=!0;const ri=4,un=8,Ut=Math.pow(2,un),gl=[.125,.215,.35,.446,.526,.582],xl=un-ri+1+gl.length,Wn=20,bs=new io,{_lodPlanes:Mi,_sizeLods:oa,_sigmas:dr}=cf(),aa=new me;let ws=null;const wn=(1+Math.sqrt(5))/2,qn=1/wn,la=[new w(1,1,1),new w(-1,1,1),new w(1,1,-1),new w(-1,1,-1),new w(0,wn,qn),new w(0,wn,-qn),new w(qn,0,wn),new w(-qn,0,wn),new w(wn,qn,0),new w(-wn,qn,0)];class ca{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=hf(Wn),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){ws=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=da(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=ua(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let e=0;e<Mi.length;e++)Mi[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ws),e.scissorTest=!1,fr(e,0,0,e.width,e.height)}_fromTexture(e,t){ws=this._renderer.getRenderTarget();const n=t||this._allocateTargets(e);return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(e){const t={magFilter:ut,minFilter:ut,generateMipmaps:!1,type:ti,format:xt,encoding:mn,depthBuffer:!1},n=ha(t);return n.depthBuffer=!e,this._pingPongRenderTarget===null&&(this._pingPongRenderTarget=ha(t)),n}_compileMaterial(e){const t=new st(Mi[0],e);this._renderer.compile(t,bs)}_sceneToCubeUV(e,t,n,i){const a=new gt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(aa),h.toneMapping=cn,h.autoClear=!1;const p=new Qs({name:"PMREM.Background",side:it,depthWrite:!1,depthTest:!1}),g=new st(new ki,p);let x=!1;const v=e.background;v?v.isColor&&(p.color.copy(v),e.background=null,x=!0):(p.color.copy(aa),x=!0);for(let m=0;m<6;m++){const f=m%3;f===0?(a.up.set(0,c[m],0),a.lookAt(l[m],0,0)):f===1?(a.up.set(0,0,c[m]),a.lookAt(0,l[m],0)):(a.up.set(0,c[m],0),a.lookAt(0,0,l[m])),fr(i,f*Ut,m>2?Ut:0,Ut,Ut),h.setRenderTarget(i),x&&h.render(g,a),h.render(e,a)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,e.background=v}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Vi||e.mapping===Gi;i?(this._cubemapShader===null&&(this._cubemapShader=da()),this._cubemapShader.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectShader===null&&(this._equirectShader=ua());const r=i?this._cubemapShader:this._equirectShader,o=new st(Mi[0],r),a=r.uniforms;a.envMap.value=e,i||a.texelSize.value.set(1/e.image.width,1/e.image.height),fr(t,0,0,3*Ut,2*Ut),n.setRenderTarget(t),n.render(o,bs)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<xl;i++){const r=Math.sqrt(dr[i]*dr[i]-dr[i-1]*dr[i-1]),o=la[(i-1)%la.length];this._blur(e,i-1,i,r,o)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new st(Mi[i],l),d=l.uniforms,p=oa[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Wn-1),x=r/g,v=isFinite(r)?1+Math.floor(h*x):Wn;v>Wn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Wn}`);const m=[];let f=0;for(let A=0;A<Wn;++A){const L=A/x,j=Math.exp(-L*L/2);m.push(j),A===0?f+=j:A<v&&(f+=2*j)}for(let A=0;A<m.length;A++)m[A]=m[A]/f;d.envMap.value=e.texture,d.samples.value=v,d.weights.value=m,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a),d.dTheta.value=g,d.mipInt.value=un-n;const T=oa[i],y=3*Math.max(0,Ut-2*T),E=(i===0?0:2*Ut)+2*T*(i>un-ri?i-un+ri:0);fr(t,y,E,3*T,2*T),c.setRenderTarget(t),c.render(u,bs)}}function cf(){const s=[],e=[],t=[];let n=un;for(let i=0;i<xl;i++){const r=Math.pow(2,n);e.push(r);let o=1/r;i>un-ri?o=gl[i-un+ri-1]:i===0&&(o=0),t.push(o);const a=1/(r-1),c=-a/2,l=1+a/2,h=[c,c,l,c,l,l,c,c,l,l,c,l],u=6,d=6,p=3,g=2,x=1,v=new Float32Array(p*d*u),m=new Float32Array(g*d*u),f=new Float32Array(x*d*u);for(let y=0;y<u;y++){const E=y%3*2/3-1,A=y>2?0:-1,L=[E,A,0,E+2/3,A,0,E+2/3,A+1,0,E,A,0,E+2/3,A+1,0,E,A+1,0];v.set(L,p*d*y),m.set(h,g*d*y);const j=[y,y,y,y,y,y];f.set(j,x*d*y)}const T=new Xe;T.setAttribute("position",new ot(v,p)),T.setAttribute("uv",new ot(m,g)),T.setAttribute("faceIndex",new ot(f,x)),s.push(T),n>ri&&n--}return{_lodPlanes:s,_sizeLods:e,_sigmas:t}}function ha(s){const e=new At(3*Ut,3*Ut,s);return e.texture.mapping=Br,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function fr(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function hf(s){const e=new Float32Array(s),t=new w(0,1,0);return new Hr({name:"SphericalGaussianBlur",defines:{n:s},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t}},vertexShader:ro(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform int samples;
|
|
uniform float weights[ n ];
|
|
uniform bool latitudinal;
|
|
uniform float dTheta;
|
|
uniform float mipInt;
|
|
uniform vec3 poleAxis;
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
vec3 getSample( float theta, vec3 axis ) {
|
|
|
|
float cosTheta = cos( theta );
|
|
// Rodrigues' axis-angle rotation
|
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
|
|
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
|
|
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
|
|
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
|
|
}
|
|
|
|
axis = normalize( axis );
|
|
|
|
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
|
|
for ( int i = 1; i < n; i++ ) {
|
|
|
|
if ( i >= samples ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
float theta = dTheta * float( i );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
|
|
}
|
|
|
|
}
|
|
`,blending:ln,depthTest:!1,depthWrite:!1})}function ua(){const s=new Z(1,1);return new Hr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:s}},vertexShader:ro(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform vec2 texelSize;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|
vec2 uv = equirectUv( outputDirection );
|
|
|
|
vec2 f = fract( uv / texelSize - 0.5 );
|
|
uv -= f * texelSize;
|
|
vec3 tl = texture2D ( envMap, uv ).rgb;
|
|
uv.x += texelSize.x;
|
|
vec3 tr = texture2D ( envMap, uv ).rgb;
|
|
uv.y += texelSize.y;
|
|
vec3 br = texture2D ( envMap, uv ).rgb;
|
|
uv.x -= texelSize.x;
|
|
vec3 bl = texture2D ( envMap, uv ).rgb;
|
|
|
|
vec3 tm = mix( tl, tr, f.x );
|
|
vec3 bm = mix( bl, br, f.x );
|
|
gl_FragColor.rgb = mix( tm, bm, f.y );
|
|
|
|
}
|
|
`,blending:ln,depthTest:!1,depthWrite:!1})}function da(){return new Hr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ro(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
uniform float flipEnvMap;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform samplerCube envMap;
|
|
|
|
void main() {
|
|
|
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
|
|
}
|
|
`,blending:ln,depthTest:!1,depthWrite:!1})}function ro(){return`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
attribute vec3 position;
|
|
attribute vec2 uv;
|
|
attribute float faceIndex;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
// RH coordinate system; PMREM face-indexing convention
|
|
vec3 getDirection( vec2 uv, float face ) {
|
|
|
|
uv = 2.0 * uv - 1.0;
|
|
|
|
vec3 direction = vec3( uv, 1.0 );
|
|
|
|
if ( face == 0.0 ) {
|
|
|
|
direction = direction.zyx; // ( 1, v, u ) pos x
|
|
|
|
} else if ( face == 1.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
|
|
} else if ( face == 2.0 ) {
|
|
|
|
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
|
|
} else if ( face == 3.0 ) {
|
|
|
|
direction = direction.zyx;
|
|
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
|
|
} else if ( face == 4.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
|
|
} else if ( face == 5.0 ) {
|
|
|
|
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
|
|
}
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vOutputDirection = getDirection( uv, faceIndex );
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
}
|
|
`}function uf(s){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===Ns||c===Bs,h=c===Vi||c===Gi;if(l||h)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let u=e.get(a);return t===null&&(t=new ca(s)),u=l?t.fromEquirectangular(a,u):t.fromCubemap(a,u),e.set(a,u),u.texture}else{if(e.has(a))return e.get(a).texture;{const u=a.image;if(l&&u&&u.height>0||h&&u&&i(u)){t===null&&(t=new ca(s));const d=l?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",r),d.texture}else return null}}}return a}function i(a){let c=0;const l=6;for(let h=0;h<l;h++)a[h]!==void 0&&c++;return c===l}function r(a){const c=a.target;c.removeEventListener("dispose",r);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function df(s){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function ff(s,e,t,n){const i={},r=new WeakMap;function o(u){const d=u.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",o),delete i[d.id];const p=r.get(d);p&&(e.remove(p),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(u,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function c(u){const d=u.attributes;for(const g in d)e.update(d[g],34962);const p=u.morphAttributes;for(const g in p){const x=p[g];for(let v=0,m=x.length;v<m;v++)e.update(x[v],34962)}}function l(u){const d=[],p=u.index,g=u.attributes.position;let x=0;if(p!==null){const f=p.array;x=p.version;for(let T=0,y=f.length;T<y;T+=3){const E=f[T+0],A=f[T+1],L=f[T+2];d.push(E,A,A,L,L,E)}}else{const f=g.array;x=g.version;for(let T=0,y=f.length/3-1;T<y;T+=3){const E=T+0,A=T+1,L=T+2;d.push(E,A,A,L,L,E)}}const v=new(cl(d)?fl:dl)(d,1);v.version=x;const m=r.get(u);m&&e.remove(m),r.set(u,v)}function h(u){const d=r.get(u);if(d){const p=u.index;p!==null&&d.version<p.version&&l(u)}else l(u);return r.get(u)}return{get:a,update:c,getWireframeAttribute:h}}function pf(s,e,t,n){const i=n.isWebGL2;let r;function o(d){r=d}let a,c;function l(d){a=d.type,c=d.bytesPerElement}function h(d,p){s.drawElements(r,p,a,d*c),t.update(p,r,1)}function u(d,p,g){if(g===0)return;let x,v;if(i)x=s,v="drawElementsInstanced";else if(x=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",x===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}x[v](r,p,a,d*c,g),t.update(p,r,g)}this.setMode=o,this.setIndex=l,this.render=h,this.renderInstances=u}function mf(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case 4:t.triangles+=a*(r/3);break;case 1:t.lines+=a*(r/2);break;case 3:t.lines+=a*(r-1);break;case 2:t.lines+=a*r;break;case 0:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}class so extends lt{constructor(e=null,t=1,n=1,i=1){super(null),this.image={data:e,width:t,height:n,depth:i},this.magFilter=rt,this.minFilter=rt,this.wrapR=St,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}so.prototype.isDataTexture2DArray=!0;function gf(s,e){return s[0]-e[0]}function xf(s,e){return Math.abs(e[1])-Math.abs(s[1])}function fa(s,e){let t=1;const n=e.isInterleavedBufferAttribute?e.data.array:e.array;n instanceof Int8Array?t=127:n instanceof Int16Array?t=32767:n instanceof Int32Array?t=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),s.divideScalar(t)}function _f(s,e,t){const n={},i=new Float32Array(8),r=new WeakMap,o=new w,a=[];for(let l=0;l<8;l++)a[l]=[l,0];function c(l,h,u,d){const p=l.morphTargetInfluences;if(e.isWebGL2===!0){const g=h.morphAttributes.position.length;let x=r.get(h);if(x===void 0||x.count!==g){let R=function(){Y.dispose(),r.delete(h),h.removeEventListener("dispose",R)};x!==void 0&&x.texture.dispose();const f=h.morphAttributes.normal!==void 0,T=h.morphAttributes.position,y=h.morphAttributes.normal||[],E=h.attributes.position.count,A=f===!0?2:1;let L=E*A,j=1;L>e.maxTextureSize&&(j=Math.ceil(L/e.maxTextureSize),L=e.maxTextureSize);const te=new Float32Array(L*j*4*g),Y=new so(te,L,j,g);Y.format=xt,Y.type=Sn,Y.needsUpdate=!0;const _=A*4;for(let P=0;P<g;P++){const B=T[P],F=y[P],I=L*j*4*P;for(let H=0;H<B.count;H++){o.fromBufferAttribute(B,H),B.normalized===!0&&fa(o,B);const J=H*_;te[I+J+0]=o.x,te[I+J+1]=o.y,te[I+J+2]=o.z,te[I+J+3]=0,f===!0&&(o.fromBufferAttribute(F,H),F.normalized===!0&&fa(o,F),te[I+J+4]=o.x,te[I+J+5]=o.y,te[I+J+6]=o.z,te[I+J+7]=0)}}x={count:g,texture:Y,size:new Z(L,j)},r.set(h,x),h.addEventListener("dispose",R)}let v=0;for(let f=0;f<p.length;f++)v+=p[f];const m=h.morphTargetsRelative?1:1-v;d.getUniforms().setValue(s,"morphTargetBaseInfluence",m),d.getUniforms().setValue(s,"morphTargetInfluences",p),d.getUniforms().setValue(s,"morphTargetsTexture",x.texture,t),d.getUniforms().setValue(s,"morphTargetsTextureSize",x.size)}else{const g=p===void 0?0:p.length;let x=n[h.id];if(x===void 0||x.length!==g){x=[];for(let y=0;y<g;y++)x[y]=[y,0];n[h.id]=x}for(let y=0;y<g;y++){const E=x[y];E[0]=y,E[1]=p[y]}x.sort(xf);for(let y=0;y<8;y++)y<g&&x[y][1]?(a[y][0]=x[y][0],a[y][1]=x[y][1]):(a[y][0]=Number.MAX_SAFE_INTEGER,a[y][1]=0);a.sort(gf);const v=h.morphAttributes.position,m=h.morphAttributes.normal;let f=0;for(let y=0;y<8;y++){const E=a[y],A=E[0],L=E[1];A!==Number.MAX_SAFE_INTEGER&&L?(v&&h.getAttribute("morphTarget"+y)!==v[A]&&h.setAttribute("morphTarget"+y,v[A]),m&&h.getAttribute("morphNormal"+y)!==m[A]&&h.setAttribute("morphNormal"+y,m[A]),i[y]=L,f+=L):(v&&h.hasAttribute("morphTarget"+y)===!0&&h.deleteAttribute("morphTarget"+y),m&&h.hasAttribute("morphNormal"+y)===!0&&h.deleteAttribute("morphNormal"+y),i[y]=0)}const T=h.morphTargetsRelative?1:1-f;d.getUniforms().setValue(s,"morphTargetBaseInfluence",T),d.getUniforms().setValue(s,"morphTargetInfluences",i)}}return{update:c}}function vf(s,e,t,n){let i=new WeakMap;function r(c){const l=n.render.frame,h=c.geometry,u=e.get(c,h);return i.get(u)!==l&&(e.update(u),i.set(u,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),t.update(c.instanceMatrix,34962),c.instanceColor!==null&&t.update(c.instanceColor,34962)),u}function o(){i=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:o}}class _l extends lt{constructor(e=null,t=1,n=1,i=1){super(null),this.image={data:e,width:t,height:n,depth:i},this.magFilter=rt,this.minFilter=rt,this.wrapR=St,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}_l.prototype.isDataTexture3D=!0;const vl=new lt,yl=new so,Ml=new _l,bl=new Ur,pa=[],ma=[],ga=new Float32Array(16),xa=new Float32Array(9),_a=new Float32Array(4);function di(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=pa[i];if(r===void 0&&(r=new Float32Array(i),pa[i]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function _t(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function mt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Vr(s,e){let t=ma[e];t===void 0&&(t=new Int32Array(e),ma[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function yf(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function Mf(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(_t(t,e))return;s.uniform2fv(this.addr,e),mt(t,e)}}function bf(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(_t(t,e))return;s.uniform3fv(this.addr,e),mt(t,e)}}function wf(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(_t(t,e))return;s.uniform4fv(this.addr,e),mt(t,e)}}function Sf(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(_t(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),mt(t,e)}else{if(_t(t,n))return;_a.set(n),s.uniformMatrix2fv(this.addr,!1,_a),mt(t,n)}}function Ef(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(_t(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),mt(t,e)}else{if(_t(t,n))return;xa.set(n),s.uniformMatrix3fv(this.addr,!1,xa),mt(t,n)}}function Tf(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(_t(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),mt(t,e)}else{if(_t(t,n))return;ga.set(n),s.uniformMatrix4fv(this.addr,!1,ga),mt(t,n)}}function Af(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function Cf(s,e){const t=this.cache;_t(t,e)||(s.uniform2iv(this.addr,e),mt(t,e))}function Lf(s,e){const t=this.cache;_t(t,e)||(s.uniform3iv(this.addr,e),mt(t,e))}function Rf(s,e){const t=this.cache;_t(t,e)||(s.uniform4iv(this.addr,e),mt(t,e))}function Pf(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function Df(s,e){const t=this.cache;_t(t,e)||(s.uniform2uiv(this.addr,e),mt(t,e))}function If(s,e){const t=this.cache;_t(t,e)||(s.uniform3uiv(this.addr,e),mt(t,e))}function Ff(s,e){const t=this.cache;_t(t,e)||(s.uniform4uiv(this.addr,e),mt(t,e))}function Nf(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.safeSetTexture2D(e||vl,i)}function Bf(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Ml,i)}function zf(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.safeSetTextureCube(e||bl,i)}function Uf(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||yl,i)}function Of(s){switch(s){case 5126:return yf;case 35664:return Mf;case 35665:return bf;case 35666:return wf;case 35674:return Sf;case 35675:return Ef;case 35676:return Tf;case 5124:case 35670:return Af;case 35667:case 35671:return Cf;case 35668:case 35672:return Lf;case 35669:case 35673:return Rf;case 5125:return Pf;case 36294:return Df;case 36295:return If;case 36296:return Ff;case 35678:case 36198:case 36298:case 36306:case 35682:return Nf;case 35679:case 36299:case 36307:return Bf;case 35680:case 36300:case 36308:case 36293:return zf;case 36289:case 36303:case 36311:case 36292:return Uf}}function Hf(s,e){s.uniform1fv(this.addr,e)}function Vf(s,e){const t=di(e,this.size,2);s.uniform2fv(this.addr,t)}function Gf(s,e){const t=di(e,this.size,3);s.uniform3fv(this.addr,t)}function kf(s,e){const t=di(e,this.size,4);s.uniform4fv(this.addr,t)}function Wf(s,e){const t=di(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function qf(s,e){const t=di(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function Xf(s,e){const t=di(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function jf(s,e){s.uniform1iv(this.addr,e)}function Yf(s,e){s.uniform2iv(this.addr,e)}function Jf(s,e){s.uniform3iv(this.addr,e)}function Zf(s,e){s.uniform4iv(this.addr,e)}function $f(s,e){s.uniform1uiv(this.addr,e)}function Kf(s,e){s.uniform2uiv(this.addr,e)}function Qf(s,e){s.uniform3uiv(this.addr,e)}function ep(s,e){s.uniform4uiv(this.addr,e)}function tp(s,e,t){const n=e.length,i=Vr(t,n);s.uniform1iv(this.addr,i);for(let r=0;r!==n;++r)t.safeSetTexture2D(e[r]||vl,i[r])}function np(s,e,t){const n=e.length,i=Vr(t,n);s.uniform1iv(this.addr,i);for(let r=0;r!==n;++r)t.setTexture3D(e[r]||Ml,i[r])}function ip(s,e,t){const n=e.length,i=Vr(t,n);s.uniform1iv(this.addr,i);for(let r=0;r!==n;++r)t.safeSetTextureCube(e[r]||bl,i[r])}function rp(s,e,t){const n=e.length,i=Vr(t,n);s.uniform1iv(this.addr,i);for(let r=0;r!==n;++r)t.setTexture2DArray(e[r]||yl,i[r])}function sp(s){switch(s){case 5126:return Hf;case 35664:return Vf;case 35665:return Gf;case 35666:return kf;case 35674:return Wf;case 35675:return qf;case 35676:return Xf;case 5124:case 35670:return jf;case 35667:case 35671:return Yf;case 35668:case 35672:return Jf;case 35669:case 35673:return Zf;case 5125:return $f;case 36294:return Kf;case 36295:return Qf;case 36296:return ep;case 35678:case 36198:case 36298:case 36306:case 35682:return tp;case 35679:case 36299:case 36307:return np;case 35680:case 36300:case 36308:case 36293:return ip;case 36289:case 36303:case 36311:case 36292:return rp}}function op(s,e,t){this.id=s,this.addr=t,this.cache=[],this.setValue=Of(e.type)}function wl(s,e,t){this.id=s,this.addr=t,this.cache=[],this.size=e.size,this.setValue=sp(e.type)}wl.prototype.updateCache=function(s){const e=this.cache;s instanceof Float32Array&&e.length!==s.length&&(this.cache=new Float32Array(s.length)),mt(e,s)};function Sl(s){this.id=s,this.seq=[],this.map={}}Sl.prototype.setValue=function(s,e,t){const n=this.seq;for(let i=0,r=n.length;i!==r;++i){const o=n[i];o.setValue(s,e[o.id],t)}};const Ss=/(\w+)(\])?(\[|\.)?/g;function va(s,e){s.seq.push(e),s.map[e.id]=e}function ap(s,e,t){const n=s.name,i=n.length;for(Ss.lastIndex=0;;){const r=Ss.exec(n),o=Ss.lastIndex;let a=r[1];const c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){va(t,l===void 0?new op(a,s,e):new wl(a,s,e));break}else{let u=t.map[a];u===void 0&&(u=new Sl(a),va(t,u)),t=u}}}function dn(s,e){this.seq=[],this.map={};const t=s.getProgramParameter(e,35718);for(let n=0;n<t;++n){const i=s.getActiveUniform(e,n),r=s.getUniformLocation(e,i.name);ap(i,r,this)}}dn.prototype.setValue=function(s,e,t,n){const i=this.map[e];i!==void 0&&i.setValue(s,t,n)};dn.prototype.setOptional=function(s,e,t){const n=e[t];n!==void 0&&this.setValue(s,t,n)};dn.upload=function(s,e,t,n){for(let i=0,r=e.length;i!==r;++i){const o=e[i],a=t[o.id];a.needsUpdate!==!1&&o.setValue(s,a.value,n)}};dn.seqWithValue=function(s,e){const t=[];for(let n=0,i=s.length;n!==i;++n){const r=s[n];r.id in e&&t.push(r)}return t};function ya(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}let lp=0;function cp(s){const e=s.split(`
|
|
`);for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join(`
|
|
`)}function hp(s){switch(s){case mn:return["Linear","( value )"];case je:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",s),["Linear","( value )"]}}function Ma(s,e,t){const n=s.getShaderParameter(e,35713),i=s.getShaderInfoLog(e).trim();return n&&i===""?"":t.toUpperCase()+`
|
|
|
|
`+i+`
|
|
|
|
`+cp(s.getShaderSource(e))}function up(s,e){const t=hp(e);return"vec4 "+s+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function dp(s,e){let t;switch(e){case Fc:t="Linear";break;case Nc:t="Reinhard";break;case Bc:t="OptimizedCineon";break;case zc:t="ACESFilmic";break;case Uc:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function fp(s){return[s.extensionDerivatives||s.envMapCubeUV||s.bumpMap||s.tangentSpaceNormalMap||s.clearcoatNormalMap||s.flatShading||s.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(s.extensionFragDepth||s.logarithmicDepthBuffer)&&s.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",s.extensionDrawBuffers&&s.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(s.extensionShaderTextureLOD||s.envMap||s.transmission)&&s.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ci).join(`
|
|
`)}function pp(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
`)}function mp(s,e){const t={},n=s.getProgramParameter(e,35721);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),o=r.name;let a=1;r.type===35674&&(a=2),r.type===35675&&(a=3),r.type===35676&&(a=4),t[o]={type:r.type,location:s.getAttribLocation(e,o),locationSize:a}}return t}function Ci(s){return s!==""}function ba(s,e){return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function wa(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const gp=/^[ \t]*#include +<([\w\d./]+)>/gm;function Vs(s){return s.replace(gp,xp)}function xp(s,e){const t=Pe[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return Vs(t)}const _p=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,vp=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Sa(s){return s.replace(vp,El).replace(_p,yp)}function yp(s,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),El(s,e,t,n)}function El(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function Ea(s){let e="precision "+s.precision+` float;
|
|
precision `+s.precision+" int;";return s.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:s.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}function Mp(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===il?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===dc?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===Ai&&(e="SHADOWMAP_TYPE_VSM"),e}function bp(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Vi:case Gi:e="ENVMAP_TYPE_CUBE";break;case Br:case Zs:e="ENVMAP_TYPE_CUBE_UV";break}return e}function wp(s){let e="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case Gi:case Zs:e="ENVMAP_MODE_REFRACTION";break}return e}function Sp(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case Nr:e="ENVMAP_BLENDING_MULTIPLY";break;case Dc:e="ENVMAP_BLENDING_MIX";break;case Ic:e="ENVMAP_BLENDING_ADD";break}return e}function Ep(s,e,t,n){const i=s.getContext(),r=t.defines;let o=t.vertexShader,a=t.fragmentShader;const c=Mp(t),l=bp(t),h=wp(t),u=Sp(t),d=t.isWebGL2?"":fp(t),p=pp(r),g=i.createProgram();let x,v,m=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(x=[p].filter(Ci).join(`
|
|
`),x.length>0&&(x+=`
|
|
`),v=[d,p].filter(Ci).join(`
|
|
`),v.length>0&&(v+=`
|
|
`)):(x=[Ea(t),"#define SHADER_NAME "+t.shaderName,p,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+t.maxBones,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.useVertexTexture?"#define BONE_TEXTURE":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
`].filter(Ci).join(`
|
|
`),v=[d,Ea(t),"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==cn?"#define TONE_MAPPING":"",t.toneMapping!==cn?Pe.tonemapping_pars_fragment:"",t.toneMapping!==cn?dp("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.transparent?"":"#define OPAQUE",Pe.encodings_pars_fragment,up("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
`].filter(Ci).join(`
|
|
`)),o=Vs(o),o=ba(o,t),o=wa(o,t),a=Vs(a),a=ba(a,t),a=wa(a,t),o=Sa(o),a=Sa(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(m=`#version 300 es
|
|
`,x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
`)+`
|
|
`+x,v=["#define varying in",t.glslVersion===jo?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===jo?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
`)+`
|
|
`+v);const f=m+x+o,T=m+v+a,y=ya(i,35633,f),E=ya(i,35632,T);if(i.attachShader(g,y),i.attachShader(g,E),t.index0AttributeName!==void 0?i.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(g,0,"position"),i.linkProgram(g),s.debug.checkShaderErrors){const j=i.getProgramInfoLog(g).trim(),te=i.getShaderInfoLog(y).trim(),Y=i.getShaderInfoLog(E).trim();let _=!0,R=!0;if(i.getProgramParameter(g,35714)===!1){_=!1;const P=Ma(i,y,"vertex"),B=Ma(i,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(g,35715)+`
|
|
|
|
Program Info Log: `+j+`
|
|
`+P+`
|
|
`+B)}else j!==""?console.warn("THREE.WebGLProgram: Program Info Log:",j):(te===""||Y==="")&&(R=!1);R&&(this.diagnostics={runnable:_,programLog:j,vertexShader:{log:te,prefix:x},fragmentShader:{log:Y,prefix:v}})}i.deleteShader(y),i.deleteShader(E);let A;this.getUniforms=function(){return A===void 0&&(A=new dn(i,g)),A};let L;return this.getAttributes=function(){return L===void 0&&(L=mp(i,g)),L},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(g),this.program=void 0},this.name=t.shaderName,this.id=lp++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=y,this.fragmentShader=E,this}let Tp=0;class Ap{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(t.has(e)===!1){const n=new Cp;t.set(e,n)}return t.get(e)}}class Cp{constructor(){this.id=Tp++,this.usedTimes=0}}function Lp(s,e,t,n,i,r,o){const a=new ul,c=new Ap,l=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,d=i.floatVertexTextures,p=i.maxVertexUniforms,g=i.vertexTextures;let x=i.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(_){const P=_.skeleton.bones;if(d)return 1024;{const F=Math.floor((p-20)/4),I=Math.min(F,P.length);return I<P.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+P.length+" bones. This GPU supports "+I+"."),0):I}}function f(_,R,P,B,F){const I=B.fog,H=_.isMeshStandardMaterial?B.environment:null,J=(_.isMeshStandardMaterial?t:e).get(_.envMap||H),ce=v[_.type],U=F.isSkinnedMesh?m(F):0;_.precision!==null&&(x=i.getMaxPrecision(_.precision),x!==_.precision&&console.warn("THREE.WebGLProgram.getParameters:",_.precision,"not supported, using",x,"instead."));let X,ie,ue,ge;if(ce){const ae=Ot[ce];X=ae.vertexShader,ie=ae.fragmentShader}else X=_.vertexShader,ie=_.fragmentShader,c.update(_),ue=c.getVertexShaderID(_),ge=c.getFragmentShaderID(_);const O=s.getRenderTarget(),Be=_.alphaTest>0,fe=_.clearcoat>0;return{isWebGL2:h,shaderID:ce,shaderName:_.type,vertexShader:X,fragmentShader:ie,defines:_.defines,customVertexShaderID:ue,customFragmentShaderID:ge,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:x,instancing:F.isInstancedMesh===!0,instancingColor:F.isInstancedMesh===!0&&F.instanceColor!==null,supportsVertexTextures:g,outputEncoding:O===null?s.outputEncoding:O.isXRRenderTarget===!0?O.texture.encoding:mn,map:!!_.map,matcap:!!_.matcap,envMap:!!J,envMapMode:J&&J.mapping,envMapCubeUV:!!J&&(J.mapping===Br||J.mapping===Zs),lightMap:!!_.lightMap,aoMap:!!_.aoMap,emissiveMap:!!_.emissiveMap,bumpMap:!!_.bumpMap,normalMap:!!_.normalMap,objectSpaceNormalMap:_.normalMapType===ah,tangentSpaceNormalMap:_.normalMapType===ci,decodeVideoTexture:!!_.map&&_.map.isVideoTexture===!0&&_.map.encoding===je,clearcoat:fe,clearcoatMap:fe&&!!_.clearcoatMap,clearcoatRoughnessMap:fe&&!!_.clearcoatRoughnessMap,clearcoatNormalMap:fe&&!!_.clearcoatNormalMap,displacementMap:!!_.displacementMap,roughnessMap:!!_.roughnessMap,metalnessMap:!!_.metalnessMap,specularMap:!!_.specularMap,specularIntensityMap:!!_.specularIntensityMap,specularColorMap:!!_.specularColorMap,transparent:_.transparent,alphaMap:!!_.alphaMap,alphaTest:Be,gradientMap:!!_.gradientMap,sheen:_.sheen>0,sheenColorMap:!!_.sheenColorMap,sheenRoughnessMap:!!_.sheenRoughnessMap,transmission:_.transmission>0,transmissionMap:!!_.transmissionMap,thicknessMap:!!_.thicknessMap,combine:_.combine,vertexTangents:!!_.normalMap&&!!F.geometry&&!!F.geometry.attributes.tangent,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!F.geometry&&!!F.geometry.attributes.color&&F.geometry.attributes.color.itemSize===4,vertexUvs:!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatMap||!!_.clearcoatRoughnessMap||!!_.clearcoatNormalMap||!!_.displacementMap||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||!!_.sheenColorMap||!!_.sheenRoughnessMap,uvsVertexOnly:!(!!_.map||!!_.bumpMap||!!_.normalMap||!!_.specularMap||!!_.alphaMap||!!_.emissiveMap||!!_.roughnessMap||!!_.metalnessMap||!!_.clearcoatNormalMap||_.transmission>0||!!_.transmissionMap||!!_.thicknessMap||!!_.specularIntensityMap||!!_.specularColorMap||_.sheen>0||!!_.sheenColorMap||!!_.sheenRoughnessMap)&&!!_.displacementMap,fog:!!I,useFog:_.fog,fogExp2:I&&I.isFogExp2,flatShading:!!_.flatShading,sizeAttenuation:_.sizeAttenuation,logarithmicDepthBuffer:u,skinning:F.isSkinnedMesh===!0&&U>0,maxBones:U,useVertexTexture:d,morphTargets:!!F.geometry&&!!F.geometry.morphAttributes.position,morphNormals:!!F.geometry&&!!F.geometry.morphAttributes.normal,morphTargetsCount:!!F.geometry&&!!F.geometry.morphAttributes.position?F.geometry.morphAttributes.position.length:0,numDirLights:R.directional.length,numPointLights:R.point.length,numSpotLights:R.spot.length,numRectAreaLights:R.rectArea.length,numHemiLights:R.hemi.length,numDirLightShadows:R.directionalShadowMap.length,numPointLightShadows:R.pointShadowMap.length,numSpotLightShadows:R.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:_.dithering,shadowMapEnabled:s.shadowMap.enabled&&P.length>0,shadowMapType:s.shadowMap.type,toneMapping:_.toneMapped?s.toneMapping:cn,physicallyCorrectLights:s.physicallyCorrectLights,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===si,flipSided:_.side===it,depthPacking:_.depthPacking!==void 0?_.depthPacking:!1,index0AttributeName:_.index0AttributeName,extensionDerivatives:_.extensions&&_.extensions.derivatives,extensionFragDepth:_.extensions&&_.extensions.fragDepth,extensionDrawBuffers:_.extensions&&_.extensions.drawBuffers,extensionShaderTextureLOD:_.extensions&&_.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:_.customProgramCacheKey()}}function T(_){const R=[];if(_.shaderID?R.push(_.shaderID):(R.push(_.customVertexShaderID),R.push(_.customFragmentShaderID)),_.defines!==void 0)for(const P in _.defines)R.push(P),R.push(_.defines[P]);return _.isRawShaderMaterial===!1&&(y(R,_),E(R,_),R.push(s.outputEncoding)),R.push(_.customProgramCacheKey),R.join()}function y(_,R){_.push(R.precision),_.push(R.outputEncoding),_.push(R.envMapMode),_.push(R.combine),_.push(R.vertexUvs),_.push(R.fogExp2),_.push(R.sizeAttenuation),_.push(R.maxBones),_.push(R.morphTargetsCount),_.push(R.numDirLights),_.push(R.numPointLights),_.push(R.numSpotLights),_.push(R.numHemiLights),_.push(R.numRectAreaLights),_.push(R.numDirLightShadows),_.push(R.numPointLightShadows),_.push(R.numSpotLightShadows),_.push(R.shadowMapType),_.push(R.toneMapping),_.push(R.numClippingPlanes),_.push(R.numClipIntersection)}function E(_,R){a.disableAll(),R.isWebGL2&&a.enable(0),R.supportsVertexTextures&&a.enable(1),R.instancing&&a.enable(2),R.instancingColor&&a.enable(3),R.map&&a.enable(4),R.matcap&&a.enable(5),R.envMap&&a.enable(6),R.envMapCubeUV&&a.enable(7),R.lightMap&&a.enable(8),R.aoMap&&a.enable(9),R.emissiveMap&&a.enable(10),R.bumpMap&&a.enable(11),R.normalMap&&a.enable(12),R.objectSpaceNormalMap&&a.enable(13),R.tangentSpaceNormalMap&&a.enable(14),R.clearcoat&&a.enable(15),R.clearcoatMap&&a.enable(16),R.clearcoatRoughnessMap&&a.enable(17),R.clearcoatNormalMap&&a.enable(18),R.displacementMap&&a.enable(19),R.specularMap&&a.enable(20),R.roughnessMap&&a.enable(21),R.metalnessMap&&a.enable(22),R.gradientMap&&a.enable(23),R.alphaMap&&a.enable(24),R.alphaTest&&a.enable(25),R.vertexColors&&a.enable(26),R.vertexAlphas&&a.enable(27),R.vertexUvs&&a.enable(28),R.vertexTangents&&a.enable(29),R.uvsVertexOnly&&a.enable(30),R.fog&&a.enable(31),_.push(a.mask),a.disableAll(),R.useFog&&a.enable(0),R.flatShading&&a.enable(1),R.logarithmicDepthBuffer&&a.enable(2),R.skinning&&a.enable(3),R.useVertexTexture&&a.enable(4),R.morphTargets&&a.enable(5),R.morphNormals&&a.enable(6),R.premultipliedAlpha&&a.enable(7),R.shadowMapEnabled&&a.enable(8),R.physicallyCorrectLights&&a.enable(9),R.doubleSided&&a.enable(10),R.flipSided&&a.enable(11),R.depthPacking&&a.enable(12),R.dithering&&a.enable(13),R.specularIntensityMap&&a.enable(14),R.specularColorMap&&a.enable(15),R.transmission&&a.enable(16),R.transmissionMap&&a.enable(17),R.thicknessMap&&a.enable(18),R.sheen&&a.enable(19),R.sheenColorMap&&a.enable(20),R.sheenRoughnessMap&&a.enable(21),R.decodeVideoTexture&&a.enable(22),R.transparent&&a.enable(23),_.push(a.mask)}function A(_){const R=v[_.type];let P;if(R){const B=Ot[R];P=Sh.clone(B.uniforms)}else P=_.uniforms;return P}function L(_,R){let P;for(let B=0,F=l.length;B<F;B++){const I=l[B];if(I.cacheKey===R){P=I,++P.usedTimes;break}}return P===void 0&&(P=new Ep(s,R,_,r),l.push(P)),P}function j(_){if(--_.usedTimes===0){const R=l.indexOf(_);l[R]=l[l.length-1],l.pop(),_.destroy()}}function te(_){c.remove(_)}function Y(){c.dispose()}return{getParameters:f,getProgramCacheKey:T,getUniforms:A,acquireProgram:L,releaseProgram:j,releaseShaderCache:te,programs:l,dispose:Y}}function Rp(){let s=new WeakMap;function e(r){let o=s.get(r);return o===void 0&&(o={},s.set(r,o)),o}function t(r){s.delete(r)}function n(r,o,a){s.get(r)[o]=a}function i(){s=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function Pp(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.z!==e.z?s.z-e.z:s.id-e.id}function Ta(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Aa(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function o(u,d,p,g,x,v){let m=s[e];return m===void 0?(m={id:u.id,object:u,geometry:d,material:p,groupOrder:g,renderOrder:u.renderOrder,z:x,group:v},s[e]=m):(m.id=u.id,m.object=u,m.geometry=d,m.material=p,m.groupOrder=g,m.renderOrder=u.renderOrder,m.z=x,m.group=v),e++,m}function a(u,d,p,g,x,v){const m=o(u,d,p,g,x,v);p.transmission>0?n.push(m):p.transparent===!0?i.push(m):t.push(m)}function c(u,d,p,g,x,v){const m=o(u,d,p,g,x,v);p.transmission>0?n.unshift(m):p.transparent===!0?i.unshift(m):t.unshift(m)}function l(u,d){t.length>1&&t.sort(u||Pp),n.length>1&&n.sort(d||Ta),i.length>1&&i.sort(d||Ta)}function h(){for(let u=e,d=s.length;u<d;u++){const p=s[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:a,unshift:c,finish:h,sort:l}}function Dp(){let s=new WeakMap;function e(n,i){let r;return s.has(n)===!1?(r=new Aa,s.set(n,[r])):i>=s.get(n).length?(r=new Aa,s.get(n).push(r)):r=s.get(n)[i],r}function t(){s=new WeakMap}return{get:e,dispose:t}}function Ip(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new w,color:new me};break;case"SpotLight":t={position:new w,direction:new w,color:new me,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new w,color:new me,distance:0,decay:0};break;case"HemisphereLight":t={direction:new w,skyColor:new me,groundColor:new me};break;case"RectAreaLight":t={color:new me,position:new w,halfWidth:new w,halfHeight:new w};break}return s[e.id]=t,t}}}function Fp(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let Np=0;function Bp(s,e){return(e.castShadow?1:0)-(s.castShadow?1:0)}function zp(s,e){const t=new Ip,n=Fp(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let h=0;h<9;h++)i.probe.push(new w);const r=new w,o=new ve,a=new ve;function c(h,u){let d=0,p=0,g=0;for(let te=0;te<9;te++)i.probe[te].set(0,0,0);let x=0,v=0,m=0,f=0,T=0,y=0,E=0,A=0;h.sort(Bp);const L=u!==!0?Math.PI:1;for(let te=0,Y=h.length;te<Y;te++){const _=h[te],R=_.color,P=_.intensity,B=_.distance,F=_.shadow&&_.shadow.map?_.shadow.map.texture:null;if(_.isAmbientLight)d+=R.r*P*L,p+=R.g*P*L,g+=R.b*P*L;else if(_.isLightProbe)for(let I=0;I<9;I++)i.probe[I].addScaledVector(_.sh.coefficients[I],P);else if(_.isDirectionalLight){const I=t.get(_);if(I.color.copy(_.color).multiplyScalar(_.intensity*L),_.castShadow){const H=_.shadow,J=n.get(_);J.shadowBias=H.bias,J.shadowNormalBias=H.normalBias,J.shadowRadius=H.radius,J.shadowMapSize=H.mapSize,i.directionalShadow[x]=J,i.directionalShadowMap[x]=F,i.directionalShadowMatrix[x]=_.shadow.matrix,y++}i.directional[x]=I,x++}else if(_.isSpotLight){const I=t.get(_);if(I.position.setFromMatrixPosition(_.matrixWorld),I.color.copy(R).multiplyScalar(P*L),I.distance=B,I.coneCos=Math.cos(_.angle),I.penumbraCos=Math.cos(_.angle*(1-_.penumbra)),I.decay=_.decay,_.castShadow){const H=_.shadow,J=n.get(_);J.shadowBias=H.bias,J.shadowNormalBias=H.normalBias,J.shadowRadius=H.radius,J.shadowMapSize=H.mapSize,i.spotShadow[m]=J,i.spotShadowMap[m]=F,i.spotShadowMatrix[m]=_.shadow.matrix,A++}i.spot[m]=I,m++}else if(_.isRectAreaLight){const I=t.get(_);I.color.copy(R).multiplyScalar(P),I.halfWidth.set(_.width*.5,0,0),I.halfHeight.set(0,_.height*.5,0),i.rectArea[f]=I,f++}else if(_.isPointLight){const I=t.get(_);if(I.color.copy(_.color).multiplyScalar(_.intensity*L),I.distance=_.distance,I.decay=_.decay,_.castShadow){const H=_.shadow,J=n.get(_);J.shadowBias=H.bias,J.shadowNormalBias=H.normalBias,J.shadowRadius=H.radius,J.shadowMapSize=H.mapSize,J.shadowCameraNear=H.camera.near,J.shadowCameraFar=H.camera.far,i.pointShadow[v]=J,i.pointShadowMap[v]=F,i.pointShadowMatrix[v]=_.shadow.matrix,E++}i.point[v]=I,v++}else if(_.isHemisphereLight){const I=t.get(_);I.skyColor.copy(_.color).multiplyScalar(P*L),I.groundColor.copy(_.groundColor).multiplyScalar(P*L),i.hemi[T]=I,T++}}f>0&&(e.isWebGL2||s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=ee.LTC_FLOAT_1,i.rectAreaLTC2=ee.LTC_FLOAT_2):s.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=ee.LTC_HALF_1,i.rectAreaLTC2=ee.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=p,i.ambient[2]=g;const j=i.hash;(j.directionalLength!==x||j.pointLength!==v||j.spotLength!==m||j.rectAreaLength!==f||j.hemiLength!==T||j.numDirectionalShadows!==y||j.numPointShadows!==E||j.numSpotShadows!==A)&&(i.directional.length=x,i.spot.length=m,i.rectArea.length=f,i.point.length=v,i.hemi.length=T,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=A,i.spotShadowMap.length=A,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=E,i.spotShadowMatrix.length=A,j.directionalLength=x,j.pointLength=v,j.spotLength=m,j.rectAreaLength=f,j.hemiLength=T,j.numDirectionalShadows=y,j.numPointShadows=E,j.numSpotShadows=A,i.version=Np++)}function l(h,u){let d=0,p=0,g=0,x=0,v=0;const m=u.matrixWorldInverse;for(let f=0,T=h.length;f<T;f++){const y=h[f];if(y.isDirectionalLight){const E=i.directional[d];E.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(m),d++}else if(y.isSpotLight){const E=i.spot[g];E.position.setFromMatrixPosition(y.matrixWorld),E.position.applyMatrix4(m),E.direction.setFromMatrixPosition(y.matrixWorld),r.setFromMatrixPosition(y.target.matrixWorld),E.direction.sub(r),E.direction.transformDirection(m),g++}else if(y.isRectAreaLight){const E=i.rectArea[x];E.position.setFromMatrixPosition(y.matrixWorld),E.position.applyMatrix4(m),a.identity(),o.copy(y.matrixWorld),o.premultiply(m),a.extractRotation(o),E.halfWidth.set(y.width*.5,0,0),E.halfHeight.set(0,y.height*.5,0),E.halfWidth.applyMatrix4(a),E.halfHeight.applyMatrix4(a),x++}else if(y.isPointLight){const E=i.point[p];E.position.setFromMatrixPosition(y.matrixWorld),E.position.applyMatrix4(m),p++}else if(y.isHemisphereLight){const E=i.hemi[v];E.direction.setFromMatrixPosition(y.matrixWorld),E.direction.transformDirection(m),E.direction.normalize(),v++}}}return{setup:c,setupView:l,state:i}}function Ca(s,e){const t=new zp(s,e),n=[],i=[];function r(){n.length=0,i.length=0}function o(u){n.push(u)}function a(u){i.push(u)}function c(u){t.setup(n,u)}function l(u){t.setupView(n,u)}return{init:r,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:c,setupLightsView:l,pushLight:o,pushShadow:a}}function Up(s,e){let t=new WeakMap;function n(r,o=0){let a;return t.has(r)===!1?(a=new Ca(s,e),t.set(r,[a])):o>=t.get(r).length?(a=new Ca(s,e),t.get(r).push(a)):a=t.get(r)[o],a}function i(){t=new WeakMap}return{get:n,dispose:i}}class Tl extends ct{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=sh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}Tl.prototype.isMeshDepthMaterial=!0;class Al extends ct{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new w,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}Al.prototype.isMeshDistanceMaterial=!0;const Op=`void main() {
|
|
gl_Position = vec4( position, 1.0 );
|
|
}`,Hp=`uniform sampler2D shadow_pass;
|
|
uniform vec2 resolution;
|
|
uniform float radius;
|
|
#include <packing>
|
|
void main() {
|
|
const float samples = float( VSM_SAMPLES );
|
|
float mean = 0.0;
|
|
float squared_mean = 0.0;
|
|
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
for ( float i = 0.0; i < samples; i ++ ) {
|
|
float uvOffset = uvStart + i * uvStride;
|
|
#ifdef HORIZONTAL_PASS
|
|
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
mean += distribution.x;
|
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
#else
|
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
mean += depth;
|
|
squared_mean += depth * depth;
|
|
#endif
|
|
}
|
|
mean = mean / samples;
|
|
squared_mean = squared_mean / samples;
|
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
}`;function Cl(s,e,t){let n=new Or;const i=new Z,r=new Z,o=new ke,a=new Tl({depthPacking:oh}),c=new Al,l={},h=t.maxTextureSize,u={0:it,1:Di,2:si},d=new An({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Z},radius:{value:4}},vertexShader:Op,fragmentShader:Hp}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new Xe;g.setAttribute("position",new ot(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new st(g,d),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=il,this.render=function(y,E,A){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||y.length===0)return;const L=s.getRenderTarget(),j=s.getActiveCubeFace(),te=s.getActiveMipmapLevel(),Y=s.state;Y.setBlending(ln),Y.buffers.color.setClear(1,1,1,1),Y.buffers.depth.setTest(!0),Y.setScissorTest(!1);for(let _=0,R=y.length;_<R;_++){const P=y[_],B=P.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",P,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;i.copy(B.mapSize);const F=B.getFrameExtents();if(i.multiply(F),r.copy(B.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/F.x),i.x=r.x*F.x,B.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/F.y),i.y=r.y*F.y,B.mapSize.y=r.y)),B.map===null&&!B.isPointLightShadow&&this.type===Ai){const H={minFilter:ut,magFilter:ut,format:xt};B.map=new At(i.x,i.y,H),B.map.texture.name=P.name+".shadowMap",B.mapPass=new At(i.x,i.y,H),B.camera.updateProjectionMatrix()}if(B.map===null){const H={minFilter:rt,magFilter:rt,format:xt};B.map=new At(i.x,i.y,H),B.map.texture.name=P.name+".shadowMap",B.camera.updateProjectionMatrix()}s.setRenderTarget(B.map),s.clear();const I=B.getViewportCount();for(let H=0;H<I;H++){const J=B.getViewport(H);o.set(r.x*J.x,r.y*J.y,r.x*J.z,r.y*J.w),Y.viewport(o),B.updateMatrices(P,H),n=B.getFrustum(),T(E,A,B.camera,P,this.type)}!B.isPointLightShadow&&this.type===Ai&&m(B,A),B.needsUpdate=!1}v.needsUpdate=!1,s.setRenderTarget(L,j,te)};function m(y,E){const A=e.update(x);d.defines.VSM_SAMPLES!==y.blurSamples&&(d.defines.VSM_SAMPLES=y.blurSamples,p.defines.VSM_SAMPLES=y.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),d.uniforms.shadow_pass.value=y.map.texture,d.uniforms.resolution.value=y.mapSize,d.uniforms.radius.value=y.radius,s.setRenderTarget(y.mapPass),s.clear(),s.renderBufferDirect(E,null,A,d,x,null),p.uniforms.shadow_pass.value=y.mapPass.texture,p.uniforms.resolution.value=y.mapSize,p.uniforms.radius.value=y.radius,s.setRenderTarget(y.map),s.clear(),s.renderBufferDirect(E,null,A,p,x,null)}function f(y,E,A,L,j,te,Y){let _=null;const R=L.isPointLight===!0?y.customDistanceMaterial:y.customDepthMaterial;if(R!==void 0?_=R:_=L.isPointLight===!0?c:a,s.localClippingEnabled&&A.clipShadows===!0&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0){const P=_.uuid,B=A.uuid;let F=l[P];F===void 0&&(F={},l[P]=F);let I=F[B];I===void 0&&(I=_.clone(),F[B]=I),_=I}return _.visible=A.visible,_.wireframe=A.wireframe,Y===Ai?_.side=A.shadowSide!==null?A.shadowSide:A.side:_.side=A.shadowSide!==null?A.shadowSide:u[A.side],_.alphaMap=A.alphaMap,_.alphaTest=A.alphaTest,_.clipShadows=A.clipShadows,_.clippingPlanes=A.clippingPlanes,_.clipIntersection=A.clipIntersection,_.displacementMap=A.displacementMap,_.displacementScale=A.displacementScale,_.displacementBias=A.displacementBias,_.wireframeLinewidth=A.wireframeLinewidth,_.linewidth=A.linewidth,L.isPointLight===!0&&_.isMeshDistanceMaterial===!0&&(_.referencePosition.setFromMatrixPosition(L.matrixWorld),_.nearDistance=j,_.farDistance=te),_}function T(y,E,A,L,j){if(y.visible===!1)return;if(y.layers.test(E.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&j===Ai)&&(!y.frustumCulled||n.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,y.matrixWorld);const _=e.update(y),R=y.material;if(Array.isArray(R)){const P=_.groups;for(let B=0,F=P.length;B<F;B++){const I=P[B],H=R[I.materialIndex];if(H&&H.visible){const J=f(y,_,H,L,A.near,A.far,j);s.renderBufferDirect(A,null,_,J,y,I)}}}else if(R.visible){const P=f(y,_,R,L,A.near,A.far,j);s.renderBufferDirect(A,null,_,P,y,null)}}const Y=y.children;for(let _=0,R=Y.length;_<R;_++)T(Y[_],E,A,L,j)}}function Vp(s,e,t){const n=t.isWebGL2;function i(){let C=!1;const he=new ke;let oe=null;const Me=new ke(0,0,0,0);return{setMask:function(W){oe!==W&&!C&&(s.colorMask(W,W,W,W),oe=W)},setLocked:function(W){C=W},setClear:function(W,_e,De,Ze,yt){yt===!0&&(W*=Ze,_e*=Ze,De*=Ze),he.set(W,_e,De,Ze),Me.equals(he)===!1&&(s.clearColor(W,_e,De,Ze),Me.copy(he))},reset:function(){C=!1,oe=null,Me.set(-1,0,0,0)}}}function r(){let C=!1,he=null,oe=null,Me=null;return{setTest:function(W){W?O(2929):Be(2929)},setMask:function(W){he!==W&&!C&&(s.depthMask(W),he=W)},setFunc:function(W){if(oe!==W){if(W)switch(W){case Ec:s.depthFunc(512);break;case Tc:s.depthFunc(519);break;case Ac:s.depthFunc(513);break;case Fs:s.depthFunc(515);break;case Cc:s.depthFunc(514);break;case Lc:s.depthFunc(518);break;case Rc:s.depthFunc(516);break;case Pc:s.depthFunc(517);break;default:s.depthFunc(515)}else s.depthFunc(515);oe=W}},setLocked:function(W){C=W},setClear:function(W){Me!==W&&(s.clearDepth(W),Me=W)},reset:function(){C=!1,he=null,oe=null,Me=null}}}function o(){let C=!1,he=null,oe=null,Me=null,W=null,_e=null,De=null,Ze=null,yt=null;return{setTest:function(Ke){C||(Ke?O(2960):Be(2960))},setMask:function(Ke){he!==Ke&&!C&&(s.stencilMask(Ke),he=Ke)},setFunc:function(Ke,Ft,kt){(oe!==Ke||Me!==Ft||W!==kt)&&(s.stencilFunc(Ke,Ft,kt),oe=Ke,Me=Ft,W=kt)},setOp:function(Ke,Ft,kt){(_e!==Ke||De!==Ft||Ze!==kt)&&(s.stencilOp(Ke,Ft,kt),_e=Ke,De=Ft,Ze=kt)},setLocked:function(Ke){C=Ke},setClear:function(Ke){yt!==Ke&&(s.clearStencil(Ke),yt=Ke)},reset:function(){C=!1,he=null,oe=null,Me=null,W=null,_e=null,De=null,Ze=null,yt=null}}}const a=new i,c=new r,l=new o;let h={},u={},d=new WeakMap,p=[],g=null,x=!1,v=null,m=null,f=null,T=null,y=null,E=null,A=null,L=!1,j=null,te=null,Y=null,_=null,R=null;const P=s.getParameter(35661);let B=!1,F=0;const I=s.getParameter(7938);I.indexOf("WebGL")!==-1?(F=parseFloat(/^WebGL (\d)/.exec(I)[1]),B=F>=1):I.indexOf("OpenGL ES")!==-1&&(F=parseFloat(/^OpenGL ES (\d)/.exec(I)[1]),B=F>=2);let H=null,J={};const ce=s.getParameter(3088),U=s.getParameter(2978),X=new ke().fromArray(ce),ie=new ke().fromArray(U);function ue(C,he,oe){const Me=new Uint8Array(4),W=s.createTexture();s.bindTexture(C,W),s.texParameteri(C,10241,9728),s.texParameteri(C,10240,9728);for(let _e=0;_e<oe;_e++)s.texImage2D(he+_e,0,6408,1,1,0,6408,5121,Me);return W}const ge={};ge[3553]=ue(3553,3553,1),ge[34067]=ue(34067,34069,6),a.setClear(0,0,0,1),c.setClear(1),l.setClear(0),O(2929),c.setFunc(Fs),$(!1),le(_o),O(2884),k(ln);function O(C){h[C]!==!0&&(s.enable(C),h[C]=!0)}function Be(C){h[C]!==!1&&(s.disable(C),h[C]=!1)}function fe(C,he){return u[C]!==he?(s.bindFramebuffer(C,he),u[C]=he,n&&(C===36009&&(u[36160]=he),C===36160&&(u[36009]=he)),!0):!1}function be(C,he){let oe=p,Me=!1;if(C)if(oe=d.get(he),oe===void 0&&(oe=[],d.set(he,oe)),C.isWebGLMultipleRenderTargets){const W=C.texture;if(oe.length!==W.length||oe[0]!==36064){for(let _e=0,De=W.length;_e<De;_e++)oe[_e]=36064+_e;oe.length=W.length,Me=!0}}else oe[0]!==36064&&(oe[0]=36064,Me=!0);else oe[0]!==1029&&(oe[0]=1029,Me=!0);Me&&(t.isWebGL2?s.drawBuffers(oe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(oe))}function ae(C){return g!==C?(s.useProgram(C),g=C,!0):!1}const Ce={[Zn]:32774,[pc]:32778,[mc]:32779};if(n)Ce[bo]=32775,Ce[wo]=32776;else{const C=e.get("EXT_blend_minmax");C!==null&&(Ce[bo]=C.MIN_EXT,Ce[wo]=C.MAX_EXT)}const we={[gc]:0,[xc]:1,[_c]:768,[sl]:770,[Sc]:776,[bc]:774,[yc]:772,[vc]:769,[ol]:771,[wc]:775,[Mc]:773};function k(C,he,oe,Me,W,_e,De,Ze){if(C===ln){x===!0&&(Be(3042),x=!1);return}if(x===!1&&(O(3042),x=!0),C!==fc){if(C!==v||Ze!==L){if((m!==Zn||y!==Zn)&&(s.blendEquation(32774),m=Zn,y=Zn),Ze)switch(C){case Li:s.blendFuncSeparate(1,771,1,771);break;case vo:s.blendFunc(1,1);break;case yo:s.blendFuncSeparate(0,769,0,1);break;case Mo:s.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}else switch(C){case Li:s.blendFuncSeparate(770,771,1,771);break;case vo:s.blendFunc(770,1);break;case yo:s.blendFuncSeparate(0,769,0,1);break;case Mo:s.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}f=null,T=null,E=null,A=null,v=C,L=Ze}return}W=W||he,_e=_e||oe,De=De||Me,(he!==m||W!==y)&&(s.blendEquationSeparate(Ce[he],Ce[W]),m=he,y=W),(oe!==f||Me!==T||_e!==E||De!==A)&&(s.blendFuncSeparate(we[oe],we[Me],we[_e],we[De]),f=oe,T=Me,E=_e,A=De),v=C,L=null}function Q(C,he){C.side===si?Be(2884):O(2884);let oe=C.side===it;he&&(oe=!oe),$(oe),C.blending===Li&&C.transparent===!1?k(ln):k(C.blending,C.blendEquation,C.blendSrc,C.blendDst,C.blendEquationAlpha,C.blendSrcAlpha,C.blendDstAlpha,C.premultipliedAlpha),c.setFunc(C.depthFunc),c.setTest(C.depthTest),c.setMask(C.depthWrite),a.setMask(C.colorWrite);const Me=C.stencilWrite;l.setTest(Me),Me&&(l.setMask(C.stencilWriteMask),l.setFunc(C.stencilFunc,C.stencilRef,C.stencilFuncMask),l.setOp(C.stencilFail,C.stencilZFail,C.stencilZPass)),ye(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),C.alphaToCoverage===!0?O(32926):Be(32926)}function $(C){j!==C&&(C?s.frontFace(2304):s.frontFace(2305),j=C)}function le(C){C!==hc?(O(2884),C!==te&&(C===_o?s.cullFace(1029):C===uc?s.cullFace(1028):s.cullFace(1032))):Be(2884),te=C}function se(C){C!==Y&&(B&&s.lineWidth(C),Y=C)}function ye(C,he,oe){C?(O(32823),(_!==he||R!==oe)&&(s.polygonOffset(he,oe),_=he,R=oe)):Be(32823)}function Se(C){C?O(3089):Be(3089)}function Ie(C){C===void 0&&(C=33984+P-1),H!==C&&(s.activeTexture(C),H=C)}function We(C,he){H===null&&Ie();let oe=J[H];oe===void 0&&(oe={type:void 0,texture:void 0},J[H]=oe),(oe.type!==C||oe.texture!==he)&&(s.bindTexture(C,he||ge[C]),oe.type=C,oe.texture=he)}function Ge(){const C=J[H];C!==void 0&&C.type!==void 0&&(s.bindTexture(C.type,null),C.type=void 0,C.texture=void 0)}function S(){try{s.compressedTexImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function M(){try{s.texSubImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function G(){try{s.texSubImage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function K(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function de(){try{s.texStorage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function V(){try{s.texStorage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function xe(){try{s.texImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function pe(){try{s.texImage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function re(C){X.equals(C)===!1&&(s.scissor(C.x,C.y,C.z,C.w),X.copy(C))}function ne(C){ie.equals(C)===!1&&(s.viewport(C.x,C.y,C.z,C.w),ie.copy(C))}function Te(){s.disable(3042),s.disable(2884),s.disable(2929),s.disable(32823),s.disable(3089),s.disable(2960),s.disable(32926),s.blendEquation(32774),s.blendFunc(1,0),s.blendFuncSeparate(1,0,1,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(513),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(519,0,4294967295),s.stencilOp(7680,7680,7680),s.clearStencil(0),s.cullFace(1029),s.frontFace(2305),s.polygonOffset(0,0),s.activeTexture(33984),s.bindFramebuffer(36160,null),n===!0&&(s.bindFramebuffer(36009,null),s.bindFramebuffer(36008,null)),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),h={},H=null,J={},u={},d=new WeakMap,p=[],g=null,x=!1,v=null,m=null,f=null,T=null,y=null,E=null,A=null,L=!1,j=null,te=null,Y=null,_=null,R=null,X.set(0,0,s.canvas.width,s.canvas.height),ie.set(0,0,s.canvas.width,s.canvas.height),a.reset(),c.reset(),l.reset()}return{buffers:{color:a,depth:c,stencil:l},enable:O,disable:Be,bindFramebuffer:fe,drawBuffers:be,useProgram:ae,setBlending:k,setMaterial:Q,setFlipSided:$,setCullFace:le,setLineWidth:se,setPolygonOffset:ye,setScissorTest:Se,activeTexture:Ie,bindTexture:We,unbindTexture:Ge,compressedTexImage2D:S,texImage2D:xe,texImage3D:pe,texStorage2D:de,texStorage3D:V,texSubImage2D:M,texSubImage3D:G,compressedTexSubImage2D:K,scissor:re,viewport:ne,reset:Te}}function Gp(s,e,t,n,i,r,o){const a=i.isWebGL2,c=i.maxTextures,l=i.maxCubemapSize,h=i.maxTextureSize,u=i.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):void 0,g=new WeakMap;let x,v=!1;try{v=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(S,M){return v?new OffscreenCanvas(S,M):Ni("canvas")}function f(S,M,G,K){let de=1;if((S.width>K||S.height>K)&&(de=K/Math.max(S.width,S.height)),de<1||M===!0)if(typeof HTMLImageElement!="undefined"&&S instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&S instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&S instanceof ImageBitmap){const V=M?hh:Math.floor,xe=V(de*S.width),pe=V(de*S.height);x===void 0&&(x=m(xe,pe));const re=G?m(xe,pe):x;return re.width=xe,re.height=pe,re.getContext("2d").drawImage(S,0,0,xe,pe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+S.width+"x"+S.height+") to ("+xe+"x"+pe+")."),re}else return"data"in S&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+S.width+"x"+S.height+")."),S;return S}function T(S){return Yo(S.width)&&Yo(S.height)}function y(S){return a?!1:S.wrapS!==St||S.wrapT!==St||S.minFilter!==rt&&S.minFilter!==ut}function E(S,M){return S.generateMipmaps&&M&&S.minFilter!==rt&&S.minFilter!==ut}function A(S){s.generateMipmap(S)}function L(S,M,G,K,de=!1){if(a===!1)return M;if(S!==null){if(s[S]!==void 0)return s[S];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+S+"'")}let V=M;return M===6403&&(G===5126&&(V=33326),G===5131&&(V=33325),G===5121&&(V=33321)),M===33319&&(G===5126&&(V=33328),G===5131&&(V=33327),G===5121&&(V=33323)),M===6408&&(G===5126&&(V=34836),G===5131&&(V=34842),G===5121&&(V=K===je&&de===!1?35907:32856),G===32819&&(V=32854),G===32820&&(V=32855)),(V===33325||V===33326||V===33327||V===33328||V===34842||V===34836)&&e.get("EXT_color_buffer_float"),V}function j(S,M,G){return E(S,G)===!0||S.isFramebufferTexture&&S.minFilter!==rt&&S.minFilter!==ut?Math.log2(Math.max(M.width,M.height))+1:S.mipmaps!==void 0&&S.mipmaps.length>0?S.mipmaps.length:S.isCompressedTexture&&Array.isArray(S.image)?M.mipmaps.length:1}function te(S){return S===rt||S===So||S===Eo?9728:9729}function Y(S){const M=S.target;M.removeEventListener("dispose",Y),R(M),M.isVideoTexture&&g.delete(M),o.memory.textures--}function _(S){const M=S.target;M.removeEventListener("dispose",_),P(M)}function R(S){const M=n.get(S);M.__webglInit!==void 0&&(s.deleteTexture(M.__webglTexture),n.remove(S))}function P(S){const M=S.texture,G=n.get(S),K=n.get(M);if(!!S){if(K.__webglTexture!==void 0&&(s.deleteTexture(K.__webglTexture),o.memory.textures--),S.depthTexture&&S.depthTexture.dispose(),S.isWebGLCubeRenderTarget)for(let de=0;de<6;de++)s.deleteFramebuffer(G.__webglFramebuffer[de]),G.__webglDepthbuffer&&s.deleteRenderbuffer(G.__webglDepthbuffer[de]);else s.deleteFramebuffer(G.__webglFramebuffer),G.__webglDepthbuffer&&s.deleteRenderbuffer(G.__webglDepthbuffer),G.__webglMultisampledFramebuffer&&s.deleteFramebuffer(G.__webglMultisampledFramebuffer),G.__webglColorRenderbuffer&&s.deleteRenderbuffer(G.__webglColorRenderbuffer),G.__webglDepthRenderbuffer&&s.deleteRenderbuffer(G.__webglDepthRenderbuffer);if(S.isWebGLMultipleRenderTargets)for(let de=0,V=M.length;de<V;de++){const xe=n.get(M[de]);xe.__webglTexture&&(s.deleteTexture(xe.__webglTexture),o.memory.textures--),n.remove(M[de])}n.remove(M),n.remove(S)}}let B=0;function F(){B=0}function I(){const S=B;return S>=c&&console.warn("THREE.WebGLTextures: Trying to use "+S+" texture units while this GPU supports only "+c),B+=1,S}function H(S,M){const G=n.get(S);if(S.isVideoTexture&&se(S),S.version>0&&G.__version!==S.version){const K=S.image;if(K===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(K.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{O(G,S,M);return}}t.activeTexture(33984+M),t.bindTexture(3553,G.__webglTexture)}function J(S,M){const G=n.get(S);if(S.version>0&&G.__version!==S.version){O(G,S,M);return}t.activeTexture(33984+M),t.bindTexture(35866,G.__webglTexture)}function ce(S,M){const G=n.get(S);if(S.version>0&&G.__version!==S.version){O(G,S,M);return}t.activeTexture(33984+M),t.bindTexture(32879,G.__webglTexture)}function U(S,M){const G=n.get(S);if(S.version>0&&G.__version!==S.version){Be(G,S,M);return}t.activeTexture(33984+M),t.bindTexture(34067,G.__webglTexture)}const X={[zs]:10497,[St]:33071,[Us]:33648},ie={[rt]:9728,[So]:9984,[Eo]:9986,[ut]:9729,[Oc]:9985,[zr]:9987};function ue(S,M,G){if(G?(s.texParameteri(S,10242,X[M.wrapS]),s.texParameteri(S,10243,X[M.wrapT]),(S===32879||S===35866)&&s.texParameteri(S,32882,X[M.wrapR]),s.texParameteri(S,10240,ie[M.magFilter]),s.texParameteri(S,10241,ie[M.minFilter])):(s.texParameteri(S,10242,33071),s.texParameteri(S,10243,33071),(S===32879||S===35866)&&s.texParameteri(S,32882,33071),(M.wrapS!==St||M.wrapT!==St)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(S,10240,te(M.magFilter)),s.texParameteri(S,10241,te(M.minFilter)),M.minFilter!==rt&&M.minFilter!==ut&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const K=e.get("EXT_texture_filter_anisotropic");if(M.type===Sn&&e.has("OES_texture_float_linear")===!1||a===!1&&M.type===ti&&e.has("OES_texture_half_float_linear")===!1)return;(M.anisotropy>1||n.get(M).__currentAnisotropy)&&(s.texParameterf(S,K.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,i.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy)}}function ge(S,M){S.__webglInit===void 0&&(S.__webglInit=!0,M.addEventListener("dispose",Y),S.__webglTexture=s.createTexture(),o.memory.textures++)}function O(S,M,G){let K=3553;M.isDataTexture2DArray&&(K=35866),M.isDataTexture3D&&(K=32879),ge(S,M),t.activeTexture(33984+G),t.bindTexture(K,S.__webglTexture),s.pixelStorei(37440,M.flipY),s.pixelStorei(37441,M.premultiplyAlpha),s.pixelStorei(3317,M.unpackAlignment),s.pixelStorei(37443,0);const de=y(M)&&T(M.image)===!1;let V=f(M.image,de,!1,h);V=ye(M,V);const xe=T(V)||a,pe=r.convert(M.format,M.encoding);let re=r.convert(M.type),ne=L(M.internalFormat,pe,re,M.encoding,M.isVideoTexture);ue(K,M,xe);let Te;const C=M.mipmaps,he=a&&M.isVideoTexture!==!0,oe=S.__version===void 0,Me=j(M,V,xe);if(M.isDepthTexture)ne=6402,a?M.type===Sn?ne=36012:M.type===Ar?ne=33190:M.type===ni?ne=35056:ne=33189:M.type===Sn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),M.format===Tn&&ne===6402&&M.type!==Ii&&M.type!==Ar&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),M.type=Ii,re=r.convert(M.type)),M.format===oi&&ne===6402&&(ne=34041,M.type!==ni&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),M.type=ni,re=r.convert(M.type))),he&&oe?t.texStorage2D(3553,1,ne,V.width,V.height):t.texImage2D(3553,0,ne,V.width,V.height,0,pe,re,null);else if(M.isDataTexture)if(C.length>0&&xe){he&&oe&&t.texStorage2D(3553,Me,ne,C[0].width,C[0].height);for(let W=0,_e=C.length;W<_e;W++)Te=C[W],he?t.texSubImage2D(3553,0,0,0,Te.width,Te.height,pe,re,Te.data):t.texImage2D(3553,W,ne,Te.width,Te.height,0,pe,re,Te.data);M.generateMipmaps=!1}else he?(oe&&t.texStorage2D(3553,Me,ne,V.width,V.height),t.texSubImage2D(3553,0,0,0,V.width,V.height,pe,re,V.data)):t.texImage2D(3553,0,ne,V.width,V.height,0,pe,re,V.data);else if(M.isCompressedTexture){he&&oe&&t.texStorage2D(3553,Me,ne,C[0].width,C[0].height);for(let W=0,_e=C.length;W<_e;W++)Te=C[W],M.format!==xt?pe!==null?he?t.compressedTexSubImage2D(3553,W,0,0,Te.width,Te.height,pe,Te.data):t.compressedTexImage2D(3553,W,ne,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):he?t.texSubImage2D(3553,W,0,0,Te.width,Te.height,pe,re,Te.data):t.texImage2D(3553,W,ne,Te.width,Te.height,0,pe,re,Te.data)}else if(M.isDataTexture2DArray)he?(oe&&t.texStorage3D(35866,Me,ne,V.width,V.height,V.depth),t.texSubImage3D(35866,0,0,0,0,V.width,V.height,V.depth,pe,re,V.data)):t.texImage3D(35866,0,ne,V.width,V.height,V.depth,0,pe,re,V.data);else if(M.isDataTexture3D)he?(oe&&t.texStorage3D(32879,Me,ne,V.width,V.height,V.depth),t.texSubImage3D(32879,0,0,0,0,V.width,V.height,V.depth,pe,re,V.data)):t.texImage3D(32879,0,ne,V.width,V.height,V.depth,0,pe,re,V.data);else if(M.isFramebufferTexture)he&&oe?t.texStorage2D(3553,Me,ne,V.width,V.height):t.texImage2D(3553,0,ne,V.width,V.height,0,pe,re,null);else if(C.length>0&&xe){he&&oe&&t.texStorage2D(3553,Me,ne,C[0].width,C[0].height);for(let W=0,_e=C.length;W<_e;W++)Te=C[W],he?t.texSubImage2D(3553,W,0,0,pe,re,Te):t.texImage2D(3553,W,ne,pe,re,Te);M.generateMipmaps=!1}else he?(oe&&t.texStorage2D(3553,Me,ne,V.width,V.height),t.texSubImage2D(3553,0,0,0,pe,re,V)):t.texImage2D(3553,0,ne,pe,re,V);E(M,xe)&&A(K),S.__version=M.version,M.onUpdate&&M.onUpdate(M)}function Be(S,M,G){if(M.image.length!==6)return;ge(S,M),t.activeTexture(33984+G),t.bindTexture(34067,S.__webglTexture),s.pixelStorei(37440,M.flipY),s.pixelStorei(37441,M.premultiplyAlpha),s.pixelStorei(3317,M.unpackAlignment),s.pixelStorei(37443,0);const K=M&&(M.isCompressedTexture||M.image[0].isCompressedTexture),de=M.image[0]&&M.image[0].isDataTexture,V=[];for(let W=0;W<6;W++)!K&&!de?V[W]=f(M.image[W],!1,!0,l):V[W]=de?M.image[W].image:M.image[W],V[W]=ye(M,V[W]);const xe=V[0],pe=T(xe)||a,re=r.convert(M.format,M.encoding),ne=r.convert(M.type),Te=L(M.internalFormat,re,ne,M.encoding),C=a&&M.isVideoTexture!==!0,he=S.__version===void 0;let oe=j(M,xe,pe);ue(34067,M,pe);let Me;if(K){C&&he&&t.texStorage2D(34067,oe,Te,xe.width,xe.height);for(let W=0;W<6;W++){Me=V[W].mipmaps;for(let _e=0;_e<Me.length;_e++){const De=Me[_e];M.format!==xt?re!==null?C?t.compressedTexSubImage2D(34069+W,_e,0,0,De.width,De.height,re,De.data):t.compressedTexImage2D(34069+W,_e,Te,De.width,De.height,0,De.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):C?t.texSubImage2D(34069+W,_e,0,0,De.width,De.height,re,ne,De.data):t.texImage2D(34069+W,_e,Te,De.width,De.height,0,re,ne,De.data)}}}else{Me=M.mipmaps,C&&he&&(Me.length>0&&oe++,t.texStorage2D(34067,oe,Te,V[0].width,V[0].height));for(let W=0;W<6;W++)if(de){C?t.texSubImage2D(34069+W,0,0,0,V[W].width,V[W].height,re,ne,V[W].data):t.texImage2D(34069+W,0,Te,V[W].width,V[W].height,0,re,ne,V[W].data);for(let _e=0;_e<Me.length;_e++){const Ze=Me[_e].image[W].image;C?t.texSubImage2D(34069+W,_e+1,0,0,Ze.width,Ze.height,re,ne,Ze.data):t.texImage2D(34069+W,_e+1,Te,Ze.width,Ze.height,0,re,ne,Ze.data)}}else{C?t.texSubImage2D(34069+W,0,0,0,re,ne,V[W]):t.texImage2D(34069+W,0,Te,re,ne,V[W]);for(let _e=0;_e<Me.length;_e++){const De=Me[_e];C?t.texSubImage2D(34069+W,_e+1,0,0,re,ne,De.image[W]):t.texImage2D(34069+W,_e+1,Te,re,ne,De.image[W])}}}E(M,pe)&&A(34067),S.__version=M.version,M.onUpdate&&M.onUpdate(M)}function fe(S,M,G,K,de){const V=r.convert(G.format,G.encoding),xe=r.convert(G.type),pe=L(G.internalFormat,V,xe,G.encoding);n.get(M).__hasExternalTextures||(de===32879||de===35866?t.texImage3D(de,0,pe,M.width,M.height,M.depth,0,V,xe,null):t.texImage2D(de,0,pe,M.width,M.height,0,V,xe,null)),t.bindFramebuffer(36160,S),M.useRenderToTexture?p.framebufferTexture2DMultisampleEXT(36160,K,de,n.get(G).__webglTexture,0,le(M)):s.framebufferTexture2D(36160,K,de,n.get(G).__webglTexture,0),t.bindFramebuffer(36160,null)}function be(S,M,G){if(s.bindRenderbuffer(36161,S),M.depthBuffer&&!M.stencilBuffer){let K=33189;if(G||M.useRenderToTexture){const de=M.depthTexture;de&&de.isDepthTexture&&(de.type===Sn?K=36012:de.type===Ar&&(K=33190));const V=le(M);M.useRenderToTexture?p.renderbufferStorageMultisampleEXT(36161,V,K,M.width,M.height):s.renderbufferStorageMultisample(36161,V,K,M.width,M.height)}else s.renderbufferStorage(36161,K,M.width,M.height);s.framebufferRenderbuffer(36160,36096,36161,S)}else if(M.depthBuffer&&M.stencilBuffer){const K=le(M);G&&M.useRenderbuffer?s.renderbufferStorageMultisample(36161,K,35056,M.width,M.height):M.useRenderToTexture?p.renderbufferStorageMultisampleEXT(36161,K,35056,M.width,M.height):s.renderbufferStorage(36161,34041,M.width,M.height),s.framebufferRenderbuffer(36160,33306,36161,S)}else{const K=M.isWebGLMultipleRenderTargets===!0?M.texture[0]:M.texture,de=r.convert(K.format,K.encoding),V=r.convert(K.type),xe=L(K.internalFormat,de,V,K.encoding),pe=le(M);G&&M.useRenderbuffer?s.renderbufferStorageMultisample(36161,pe,xe,M.width,M.height):M.useRenderToTexture?p.renderbufferStorageMultisampleEXT(36161,pe,xe,M.width,M.height):s.renderbufferStorage(36161,xe,M.width,M.height)}s.bindRenderbuffer(36161,null)}function ae(S,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,S),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),H(M.depthTexture,0);const K=n.get(M.depthTexture).__webglTexture,de=le(M);if(M.depthTexture.format===Tn)M.useRenderToTexture?p.framebufferTexture2DMultisampleEXT(36160,36096,3553,K,0,de):s.framebufferTexture2D(36160,36096,3553,K,0);else if(M.depthTexture.format===oi)M.useRenderToTexture?p.framebufferTexture2DMultisampleEXT(36160,33306,3553,K,0,de):s.framebufferTexture2D(36160,33306,3553,K,0);else throw new Error("Unknown depthTexture format")}function Ce(S){const M=n.get(S),G=S.isWebGLCubeRenderTarget===!0;if(S.depthTexture&&!M.__autoAllocateDepthBuffer){if(G)throw new Error("target.depthTexture not supported in Cube render targets");ae(M.__webglFramebuffer,S)}else if(G){M.__webglDepthbuffer=[];for(let K=0;K<6;K++)t.bindFramebuffer(36160,M.__webglFramebuffer[K]),M.__webglDepthbuffer[K]=s.createRenderbuffer(),be(M.__webglDepthbuffer[K],S,!1)}else t.bindFramebuffer(36160,M.__webglFramebuffer),M.__webglDepthbuffer=s.createRenderbuffer(),be(M.__webglDepthbuffer,S,!1);t.bindFramebuffer(36160,null)}function we(S,M,G){const K=n.get(S);M!==void 0&&fe(K.__webglFramebuffer,S,S.texture,36064,3553),G!==void 0&&Ce(S)}function k(S){const M=S.texture,G=n.get(S),K=n.get(M);S.addEventListener("dispose",_),S.isWebGLMultipleRenderTargets!==!0&&(K.__webglTexture===void 0&&(K.__webglTexture=s.createTexture()),K.__version=M.version,o.memory.textures++);const de=S.isWebGLCubeRenderTarget===!0,V=S.isWebGLMultipleRenderTargets===!0,xe=M.isDataTexture3D||M.isDataTexture2DArray,pe=T(S)||a;if(de){G.__webglFramebuffer=[];for(let re=0;re<6;re++)G.__webglFramebuffer[re]=s.createFramebuffer()}else if(G.__webglFramebuffer=s.createFramebuffer(),V)if(i.drawBuffers){const re=S.texture;for(let ne=0,Te=re.length;ne<Te;ne++){const C=n.get(re[ne]);C.__webglTexture===void 0&&(C.__webglTexture=s.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(S.useRenderbuffer)if(a){G.__webglMultisampledFramebuffer=s.createFramebuffer(),G.__webglColorRenderbuffer=s.createRenderbuffer(),s.bindRenderbuffer(36161,G.__webglColorRenderbuffer);const re=r.convert(M.format,M.encoding),ne=r.convert(M.type),Te=L(M.internalFormat,re,ne,M.encoding),C=le(S);s.renderbufferStorageMultisample(36161,C,Te,S.width,S.height),t.bindFramebuffer(36160,G.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(36160,36064,36161,G.__webglColorRenderbuffer),s.bindRenderbuffer(36161,null),S.depthBuffer&&(G.__webglDepthRenderbuffer=s.createRenderbuffer(),be(G.__webglDepthRenderbuffer,S,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(de){t.bindTexture(34067,K.__webglTexture),ue(34067,M,pe);for(let re=0;re<6;re++)fe(G.__webglFramebuffer[re],S,M,36064,34069+re);E(M,pe)&&A(34067),t.unbindTexture()}else if(V){const re=S.texture;for(let ne=0,Te=re.length;ne<Te;ne++){const C=re[ne],he=n.get(C);t.bindTexture(3553,he.__webglTexture),ue(3553,C,pe),fe(G.__webglFramebuffer,S,C,36064+ne,3553),E(C,pe)&&A(3553)}t.unbindTexture()}else{let re=3553;xe&&(a?re=M.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),t.bindTexture(re,K.__webglTexture),ue(re,M,pe),fe(G.__webglFramebuffer,S,M,36064,re),E(M,pe)&&A(re),t.unbindTexture()}S.depthBuffer&&Ce(S)}function Q(S){const M=T(S)||a,G=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let K=0,de=G.length;K<de;K++){const V=G[K];if(E(V,M)){const xe=S.isWebGLCubeRenderTarget?34067:3553,pe=n.get(V).__webglTexture;t.bindTexture(xe,pe),A(xe),t.unbindTexture()}}}function $(S){if(S.useRenderbuffer)if(a){const M=S.width,G=S.height;let K=16384;const de=[36064],V=S.stencilBuffer?33306:36096;S.depthBuffer&&de.push(V),S.ignoreDepthForMultisampleCopy||(S.depthBuffer&&(K|=256),S.stencilBuffer&&(K|=1024));const xe=n.get(S);t.bindFramebuffer(36008,xe.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,xe.__webglFramebuffer),S.ignoreDepthForMultisampleCopy&&(s.invalidateFramebuffer(36008,[V]),s.invalidateFramebuffer(36009,[V])),s.blitFramebuffer(0,0,M,G,0,0,M,G,K,9728),s.invalidateFramebuffer(36008,de),t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,xe.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function le(S){return a&&(S.useRenderbuffer||S.useRenderToTexture)?Math.min(u,S.samples):0}function se(S){const M=o.render.frame;g.get(S)!==M&&(g.set(S,M),S.update())}function ye(S,M){const G=S.encoding,K=S.format,de=S.type;return S.isCompressedTexture===!0||S.isVideoTexture===!0||S.format===Os||G!==mn&&(G===je?a===!1?e.has("EXT_sRGB")===!0&&K===xt?(S.format=Os,S.minFilter=ut,S.generateMipmaps=!1):M=Ln.sRGBToLinear(M):(K!==xt||de!==hn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",G)),M}let Se=!1,Ie=!1;function We(S,M){S&&S.isWebGLRenderTarget&&(Se===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),Se=!0),S=S.texture),H(S,M)}function Ge(S,M){S&&S.isWebGLCubeRenderTarget&&(Ie===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),Ie=!0),S=S.texture),U(S,M)}this.allocateTextureUnit=I,this.resetTextureUnits=F,this.setTexture2D=H,this.setTexture2DArray=J,this.setTexture3D=ce,this.setTextureCube=U,this.rebindTextures=we,this.setupRenderTarget=k,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=$,this.setupDepthRenderbuffer=Ce,this.setupFrameBufferTexture=fe,this.safeSetTexture2D=We,this.safeSetTextureCube=Ge}function kp(s,e,t){const n=t.isWebGL2;function i(r,o=null){let a;if(r===hn)return 5121;if(r===kc)return 32819;if(r===Wc)return 32820;if(r===Hc)return 5120;if(r===Vc)return 5122;if(r===Ii)return 5123;if(r===Gc)return 5124;if(r===Ar)return 5125;if(r===Sn)return 5126;if(r===ti)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(r===qc)return 6406;if(r===xt)return 6408;if(r===jc)return 6409;if(r===Yc)return 6410;if(r===Tn)return 6402;if(r===oi)return 34041;if(r===Jc)return 6403;if(r===Xc)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(r===Os)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(r===Zc)return 36244;if(r===$c)return 33319;if(r===Kc)return 33320;if(r===Qc)return 36249;if(r===jr||r===Yr||r===Jr||r===Zr)if(o===je)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===jr)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===Yr)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===Jr)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===Zr)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===jr)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===Yr)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===Jr)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===Zr)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===To||r===Ao||r===Co||r===Lo)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===To)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Ao)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Co)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Lo)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===eh)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===Ro||r===Po)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===Ro)return o===je?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===Po)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===Do||r===Io||r===Fo||r===No||r===Bo||r===zo||r===Uo||r===Oo||r===Ho||r===Vo||r===Go||r===ko||r===Wo||r===qo)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===Do)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Io)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Fo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===No)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Bo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===zo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Uo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Oo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Ho)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Vo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Go)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===ko)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===Wo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===qo)return o===je?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Xo)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===Xo)return o===je?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===ni)return n?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:i}}class Ll extends gt{constructor(e=[]){super(),this.cameras=e}}Ll.prototype.isArrayCamera=!0;class En extends Ue{constructor(){super(),this.type="Group"}}En.prototype.isGroup=!0;const Wp={type:"move"};class Es{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new En,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new En,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new w,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new w),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new En,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new w,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new w),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(a!==null&&(i=t.getPose(e.targetRaySpace,n),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Wp))),l&&e.hand){o=!0;for(const x of e.hand.values()){const v=t.getJointPose(x,n);if(l.joints[x.jointName]===void 0){const f=new En;f.matrixAutoUpdate=!1,f.visible=!1,l.joints[x.jointName]=f,l.add(f)}const m=l.joints[x.jointName];v!==null&&(m.matrix.fromArray(v.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=v.radius),m.visible=v!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,g=.005;l.inputState.pinching&&d>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}}class Gs extends lt{constructor(e,t,n,i,r,o,a,c,l,h){if(h=h!==void 0?h:Tn,h!==Tn&&h!==oi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===Tn&&(n=Ii),n===void 0&&h===oi&&(n=ni),super(null,i,r,o,a,c,h,n,l),this.image={width:e,height:t},this.magFilter=a!==void 0?a:rt,this.minFilter=c!==void 0?c:rt,this.flipY=!1,this.generateMipmaps=!1}}Gs.prototype.isDepthTexture=!0;class qp extends Cn{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor";const c=e.extensions.has("WEBGL_multisampled_render_to_texture");let l=null,h=null,u=null,d=null,p=!1,g=null;const x=t.getContextAttributes();let v=null,m=null;const f=[],T=new Map,y=new gt;y.layers.enable(1),y.viewport=new ke;const E=new gt;E.layers.enable(2),E.viewport=new ke;const A=[y,E],L=new Ll;L.layers.enable(1),L.layers.enable(2);let j=null,te=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let X=f[U];return X===void 0&&(X=new Es,f[U]=X),X.getTargetRaySpace()},this.getControllerGrip=function(U){let X=f[U];return X===void 0&&(X=new Es,f[U]=X),X.getGripSpace()},this.getHand=function(U){let X=f[U];return X===void 0&&(X=new Es,f[U]=X),X.getHandSpace()};function Y(U){const X=T.get(U.inputSource);X&&X.dispatchEvent({type:U.type,data:U.inputSource})}function _(){T.forEach(function(U,X){U.disconnect(X)}),T.clear(),j=null,te=null,e.setRenderTarget(v),d=null,u=null,h=null,i=null,m=null,ce.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){r=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return o},this.getBaseLayer=function(){return u!==null?u:d},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(U){if(i=U,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",Y),i.addEventListener("selectstart",Y),i.addEventListener("selectend",Y),i.addEventListener("squeeze",Y),i.addEventListener("squeezestart",Y),i.addEventListener("squeezeend",Y),i.addEventListener("end",_),i.addEventListener("inputsourceschange",R),x.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const X={antialias:i.renderState.layers===void 0?x.antialias:!0,alpha:x.alpha,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,X),i.updateRenderState({baseLayer:d}),m=new At(d.framebufferWidth,d.framebufferHeight,{format:xt,type:hn,encoding:e.outputEncoding})}else{p=x.antialias;let X=null,ie=null,ue=null;x.depth&&(ue=x.stencil?35056:33190,X=x.stencil?oi:Tn,ie=x.stencil?ni:Ii);const ge={colorFormat:e.outputEncoding===je?35907:32856,depthFormat:ue,scaleFactor:r};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(ge),i.updateRenderState({layers:[u]}),p?m=new Ks(u.textureWidth,u.textureHeight,{format:xt,type:hn,depthTexture:new Gs(u.textureWidth,u.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,X),stencilBuffer:x.stencil,ignoreDepth:u.ignoreDepthValues,useRenderToTexture:c,encoding:e.outputEncoding}):m=new At(u.textureWidth,u.textureHeight,{format:xt,type:hn,depthTexture:new Gs(u.textureWidth,u.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,X),stencilBuffer:x.stencil,ignoreDepth:u.ignoreDepthValues,encoding:e.outputEncoding})}m.isXRRenderTarget=!0,this.setFoveation(1),o=await i.requestReferenceSpace(a),ce.setContext(i),ce.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function R(U){const X=i.inputSources;for(let ie=0;ie<f.length;ie++)T.set(X[ie],f[ie]);for(let ie=0;ie<U.removed.length;ie++){const ue=U.removed[ie],ge=T.get(ue);ge&&(ge.dispatchEvent({type:"disconnected",data:ue}),T.delete(ue))}for(let ie=0;ie<U.added.length;ie++){const ue=U.added[ie],ge=T.get(ue);ge&&ge.dispatchEvent({type:"connected",data:ue})}}const P=new w,B=new w;function F(U,X,ie){P.setFromMatrixPosition(X.matrixWorld),B.setFromMatrixPosition(ie.matrixWorld);const ue=P.distanceTo(B),ge=X.projectionMatrix.elements,O=ie.projectionMatrix.elements,Be=ge[14]/(ge[10]-1),fe=ge[14]/(ge[10]+1),be=(ge[9]+1)/ge[5],ae=(ge[9]-1)/ge[5],Ce=(ge[8]-1)/ge[0],we=(O[8]+1)/O[0],k=Be*Ce,Q=Be*we,$=ue/(-Ce+we),le=$*-Ce;X.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(le),U.translateZ($),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();const se=Be+$,ye=fe+$,Se=k-le,Ie=Q+(ue-le),We=be*fe/ye*se,Ge=ae*fe/ye*se;U.projectionMatrix.makePerspective(Se,Ie,We,Ge,se,ye)}function I(U,X){X===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(X.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(i===null)return;L.near=E.near=y.near=U.near,L.far=E.far=y.far=U.far,(j!==L.near||te!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),j=L.near,te=L.far);const X=U.parent,ie=L.cameras;I(L,X);for(let ge=0;ge<ie.length;ge++)I(ie[ge],X);L.matrixWorld.decompose(L.position,L.quaternion,L.scale),U.position.copy(L.position),U.quaternion.copy(L.quaternion),U.scale.copy(L.scale),U.matrix.copy(L.matrix),U.matrixWorld.copy(L.matrixWorld);const ue=U.children;for(let ge=0,O=ue.length;ge<O;ge++)ue[ge].updateMatrixWorld(!0);ie.length===2?F(L,y,E):L.projectionMatrix.copy(y.projectionMatrix)},this.getCamera=function(){return L},this.getFoveation=function(){if(u!==null)return u.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(U){u!==null&&(u.fixedFoveation=U),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=U)};let H=null;function J(U,X){if(l=X.getViewerPose(o),g=X,l!==null){const ue=l.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let ge=!1;ue.length!==L.cameras.length&&(L.cameras.length=0,ge=!0);for(let O=0;O<ue.length;O++){const Be=ue[O];let fe=null;if(d!==null)fe=d.getViewport(Be);else{const ae=h.getViewSubImage(u,Be);fe=ae.viewport,O===0&&(e.setRenderTargetTextures(m,ae.colorTexture,u.ignoreDepthValues?void 0:ae.depthStencilTexture),e.setRenderTarget(m))}const be=A[O];be.matrix.fromArray(Be.transform.matrix),be.projectionMatrix.fromArray(Be.projectionMatrix),be.viewport.set(fe.x,fe.y,fe.width,fe.height),O===0&&L.matrix.copy(be.matrix),ge===!0&&L.cameras.push(be)}}const ie=i.inputSources;for(let ue=0;ue<f.length;ue++){const ge=f[ue],O=ie[ue];ge.update(O,X,o)}H&&H(U,X),g=null}const ce=new ml;ce.setAnimationLoop(J),this.setAnimationLoop=function(U){H=U},this.dispose=function(){}}}function Xp(s){function e(m,f){m.fogColor.value.copy(f.color),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function t(m,f,T,y,E){f.isMeshBasicMaterial?n(m,f):f.isMeshLambertMaterial?(n(m,f),c(m,f)):f.isMeshToonMaterial?(n(m,f),h(m,f)):f.isMeshPhongMaterial?(n(m,f),l(m,f)):f.isMeshStandardMaterial?(n(m,f),f.isMeshPhysicalMaterial?d(m,f,E):u(m,f)):f.isMeshMatcapMaterial?(n(m,f),p(m,f)):f.isMeshDepthMaterial?(n(m,f),g(m,f)):f.isMeshDistanceMaterial?(n(m,f),x(m,f)):f.isMeshNormalMaterial?(n(m,f),v(m,f)):f.isLineBasicMaterial?(i(m,f),f.isLineDashedMaterial&&r(m,f)):f.isPointsMaterial?o(m,f,T,y):f.isSpriteMaterial?a(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function n(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map),f.alphaMap&&(m.alphaMap.value=f.alphaMap),f.specularMap&&(m.specularMap.value=f.specularMap),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const T=s.get(f).envMap;T&&(m.envMap.value=T,m.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity);let y;f.map?y=f.map:f.specularMap?y=f.specularMap:f.displacementMap?y=f.displacementMap:f.normalMap?y=f.normalMap:f.bumpMap?y=f.bumpMap:f.roughnessMap?y=f.roughnessMap:f.metalnessMap?y=f.metalnessMap:f.alphaMap?y=f.alphaMap:f.emissiveMap?y=f.emissiveMap:f.clearcoatMap?y=f.clearcoatMap:f.clearcoatNormalMap?y=f.clearcoatNormalMap:f.clearcoatRoughnessMap?y=f.clearcoatRoughnessMap:f.specularIntensityMap?y=f.specularIntensityMap:f.specularColorMap?y=f.specularColorMap:f.transmissionMap?y=f.transmissionMap:f.thicknessMap?y=f.thicknessMap:f.sheenColorMap?y=f.sheenColorMap:f.sheenRoughnessMap&&(y=f.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),m.uvTransform.value.copy(y.matrix));let E;f.aoMap?E=f.aoMap:f.lightMap&&(E=f.lightMap),E!==void 0&&(E.isWebGLRenderTarget&&(E=E.texture),E.matrixAutoUpdate===!0&&E.updateMatrix(),m.uv2Transform.value.copy(E.matrix))}function i(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity}function r(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function o(m,f,T,y){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*T,m.scale.value=y*.5,f.map&&(m.map.value=f.map),f.alphaMap&&(m.alphaMap.value=f.alphaMap),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);let E;f.map?E=f.map:f.alphaMap&&(E=f.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),m.uvTransform.value.copy(E.matrix))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map),f.alphaMap&&(m.alphaMap.value=f.alphaMap),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);let T;f.map?T=f.map:f.alphaMap&&(T=f.alphaMap),T!==void 0&&(T.matrixAutoUpdate===!0&&T.updateMatrix(),m.uvTransform.value.copy(T.matrix))}function c(m,f){f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap)}function l(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap),f.bumpMap&&(m.bumpMap.value=f.bumpMap,m.bumpScale.value=f.bumpScale,f.side===it&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,m.normalScale.value.copy(f.normalScale),f.side===it&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias)}function h(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap),f.bumpMap&&(m.bumpMap.value=f.bumpMap,m.bumpScale.value=f.bumpScale,f.side===it&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,m.normalScale.value.copy(f.normalScale),f.side===it&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias)}function u(m,f){m.roughness.value=f.roughness,m.metalness.value=f.metalness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap),f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap),f.bumpMap&&(m.bumpMap.value=f.bumpMap,m.bumpScale.value=f.bumpScale,f.side===it&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,m.normalScale.value.copy(f.normalScale),f.side===it&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),s.get(f).envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function d(m,f,T){u(m,f),m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap)),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap),f.clearcoatNormalMap&&(m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),m.clearcoatNormalMap.value=f.clearcoatNormalMap,f.side===it&&m.clearcoatNormalScale.value.negate())),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap)}function p(m,f){f.matcap&&(m.matcap.value=f.matcap),f.bumpMap&&(m.bumpMap.value=f.bumpMap,m.bumpScale.value=f.bumpScale,f.side===it&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,m.normalScale.value.copy(f.normalScale),f.side===it&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias)}function g(m,f){f.displacementMap&&(m.displacementMap.value=f.displacementMap,m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias)}function x(m,f){f.displacementMap&&(m.displacementMap.value=f.displacementMap,m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),m.referencePosition.value.copy(f.referencePosition),m.nearDistance.value=f.nearDistance,m.farDistance.value=f.farDistance}function v(m,f){f.bumpMap&&(m.bumpMap.value=f.bumpMap,m.bumpScale.value=f.bumpScale,f.side===it&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,m.normalScale.value.copy(f.normalScale),f.side===it&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function jp(){const s=Ni("canvas");return s.style.display="block",s}function Ve(s={}){const e=s.canvas!==void 0?s.canvas:jp(),t=s.context!==void 0?s.context:null,n=s.alpha!==void 0?s.alpha:!1,i=s.depth!==void 0?s.depth:!0,r=s.stencil!==void 0?s.stencil:!0,o=s.antialias!==void 0?s.antialias:!1,a=s.premultipliedAlpha!==void 0?s.premultipliedAlpha:!0,c=s.preserveDrawingBuffer!==void 0?s.preserveDrawingBuffer:!1,l=s.powerPreference!==void 0?s.powerPreference:"default",h=s.failIfMajorPerformanceCaveat!==void 0?s.failIfMajorPerformanceCaveat:!1;let u=null,d=null;const p=[],g=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=mn,this.physicallyCorrectLights=!1,this.toneMapping=cn,this.toneMappingExposure=1;const x=this;let v=!1,m=0,f=0,T=null,y=-1,E=null;const A=new ke,L=new ke;let j=null,te=e.width,Y=e.height,_=1,R=null,P=null;const B=new ke(0,0,te,Y),F=new ke(0,0,te,Y);let I=!1;const H=new Or;let J=!1,ce=!1,U=null;const X=new ve,ie=new w,ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ge(){return T===null?_:1}let O=t;function Be(b,D){for(let z=0;z<b.length;z++){const N=b[z],q=e.getContext(N,D);if(q!==null)return q}return null}try{const b={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Js}`),e.addEventListener("webglcontextlost",Te,!1),e.addEventListener("webglcontextrestored",C,!1),O===null){const D=["webgl2","webgl","experimental-webgl"];if(x.isWebGL1Renderer===!0&&D.shift(),O=Be(D,b),O===null)throw Be(D)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}O.getShaderPrecisionFormat===void 0&&(O.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(b){throw console.error("THREE.WebGLRenderer: "+b.message),b}let fe,be,ae,Ce,we,k,Q,$,le,se,ye,Se,Ie,We,Ge,S,M,G,K,de,V,xe,pe;function re(){fe=new df(O),be=new of(O,fe,s),fe.init(be),xe=new kp(O,fe,be),ae=new Vp(O,fe,be),Ce=new mf,we=new Rp,k=new Gp(O,fe,ae,we,be,xe,Ce),Q=new lf(x),$=new uf(x),le=new Lh(O,be),pe=new rf(O,fe,le,be),se=new ff(O,le,Ce,pe),ye=new vf(O,se,le,Ce),K=new _f(O,be,k),S=new af(we),Se=new Lp(x,Q,$,fe,be,pe,S),Ie=new Xp(we),We=new Dp,Ge=new Up(fe,be),G=new nf(x,Q,ae,ye,n,a),M=new Cl(x,ye,be),de=new sf(O,fe,Ce,be),V=new pf(O,fe,Ce,be),Ce.programs=Se.programs,x.capabilities=be,x.extensions=fe,x.properties=we,x.renderLists=We,x.shadowMap=M,x.state=ae,x.info=Ce}re();const ne=new qp(x,O);this.xr=ne,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const b=fe.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){const b=fe.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return _},this.setPixelRatio=function(b){b!==void 0&&(_=b,this.setSize(te,Y,!1))},this.getSize=function(b){return b.set(te,Y)},this.setSize=function(b,D,z){if(ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}te=b,Y=D,e.width=Math.floor(b*_),e.height=Math.floor(D*_),z!==!1&&(e.style.width=b+"px",e.style.height=D+"px"),this.setViewport(0,0,b,D)},this.getDrawingBufferSize=function(b){return b.set(te*_,Y*_).floor()},this.setDrawingBufferSize=function(b,D,z){te=b,Y=D,_=z,e.width=Math.floor(b*z),e.height=Math.floor(D*z),this.setViewport(0,0,b,D)},this.getCurrentViewport=function(b){return b.copy(A)},this.getViewport=function(b){return b.copy(B)},this.setViewport=function(b,D,z,N){b.isVector4?B.set(b.x,b.y,b.z,b.w):B.set(b,D,z,N),ae.viewport(A.copy(B).multiplyScalar(_).floor())},this.getScissor=function(b){return b.copy(F)},this.setScissor=function(b,D,z,N){b.isVector4?F.set(b.x,b.y,b.z,b.w):F.set(b,D,z,N),ae.scissor(L.copy(F).multiplyScalar(_).floor())},this.getScissorTest=function(){return I},this.setScissorTest=function(b){ae.setScissorTest(I=b)},this.setOpaqueSort=function(b){R=b},this.setTransparentSort=function(b){P=b},this.getClearColor=function(b){return b.copy(G.getClearColor())},this.setClearColor=function(){G.setClearColor.apply(G,arguments)},this.getClearAlpha=function(){return G.getClearAlpha()},this.setClearAlpha=function(){G.setClearAlpha.apply(G,arguments)},this.clear=function(b,D,z){let N=0;(b===void 0||b)&&(N|=16384),(D===void 0||D)&&(N|=256),(z===void 0||z)&&(N|=1024),O.clear(N)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Te,!1),e.removeEventListener("webglcontextrestored",C,!1),We.dispose(),Ge.dispose(),we.dispose(),Q.dispose(),$.dispose(),ye.dispose(),pe.dispose(),Se.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",De),ne.removeEventListener("sessionend",Ze),U&&(U.dispose(),U=null),yt.stop()};function Te(b){b.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function C(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;const b=Ce.autoReset,D=M.enabled,z=M.autoUpdate,N=M.needsUpdate,q=M.type;re(),Ce.autoReset=b,M.enabled=D,M.autoUpdate=z,M.needsUpdate=N,M.type=q}function he(b){const D=b.target;D.removeEventListener("dispose",he),oe(D)}function oe(b){Me(b),we.remove(b)}function Me(b){const D=we.get(b).programs;D!==void 0&&(D.forEach(function(z){Se.releaseProgram(z)}),b.isShaderMaterial&&Se.releaseShaderCache(b))}this.renderBufferDirect=function(b,D,z,N,q,Ee){D===null&&(D=ue);const Ae=q.isMesh&&q.matrixWorld.determinant()<0,Re=nc(b,D,z,N,q);ae.setMaterial(N,Ae);let Le=z.index;const Oe=z.attributes.position;if(Le===null){if(Oe===void 0||Oe.count===0)return}else if(Le.count===0)return;let Fe=1;N.wireframe===!0&&(Le=se.getWireframeAttribute(z),Fe=2),pe.setup(q,N,Re,z,Le);let Ne,Qe=de;Le!==null&&(Ne=le.get(Le),Qe=V,Qe.setIndex(Ne));const vn=Le!==null?Le.count:Oe.count,Rn=z.drawRange.start*Fe,ze=z.drawRange.count*Fe,Nt=Ee!==null?Ee.start*Fe:0,nt=Ee!==null?Ee.count*Fe:1/0,Bt=Math.max(Rn,Nt),ji=Math.min(vn,Rn+ze,Nt+nt)-1,zt=Math.max(0,ji-Bt+1);if(zt!==0){if(q.isMesh)N.wireframe===!0?(ae.setLineWidth(N.wireframeLinewidth*ge()),Qe.setMode(1)):Qe.setMode(4);else if(q.isLine){let Wt=N.linewidth;Wt===void 0&&(Wt=1),ae.setLineWidth(Wt*ge()),q.isLineSegments?Qe.setMode(1):q.isLineLoop?Qe.setMode(2):Qe.setMode(3)}else q.isPoints?Qe.setMode(0):q.isSprite&&Qe.setMode(4);if(q.isInstancedMesh)Qe.renderInstances(Bt,zt,q.count);else if(z.isInstancedBufferGeometry){const Wt=Math.min(z.instanceCount,z._maxInstanceCount);Qe.renderInstances(Bt,zt,Wt)}else Qe.render(Bt,zt)}},this.compile=function(b,D){d=Ge.get(b),d.init(),g.push(d),b.traverseVisible(function(z){z.isLight&&z.layers.test(D.layers)&&(d.pushLight(z),z.castShadow&&d.pushShadow(z))}),d.setupLights(x.physicallyCorrectLights),b.traverse(function(z){const N=z.material;if(N)if(Array.isArray(N))for(let q=0;q<N.length;q++){const Ee=N[q];Xr(Ee,b,z)}else Xr(N,b,z)}),g.pop(),d=null};let W=null;function _e(b){W&&W(b)}function De(){yt.stop()}function Ze(){yt.start()}const yt=new ml;yt.setAnimationLoop(_e),typeof window!="undefined"&&yt.setContext(window),this.setAnimationLoop=function(b){W=b,ne.setAnimationLoop(b),b===null?yt.stop():yt.start()},ne.addEventListener("sessionstart",De),ne.addEventListener("sessionend",Ze),this.render=function(b,D){if(D!==void 0&&D.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;b.autoUpdate===!0&&b.updateMatrixWorld(),D.parent===null&&D.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(D),D=ne.getCamera()),b.isScene===!0&&b.onBeforeRender(x,b,D,T),d=Ge.get(b,g.length),d.init(),g.push(d),X.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),H.setFromProjectionMatrix(X),ce=this.localClippingEnabled,J=S.init(this.clippingPlanes,ce,D),u=We.get(b,p.length),u.init(),p.push(u),Ke(b,D,0,x.sortObjects),u.finish(),x.sortObjects===!0&&u.sort(R,P),J===!0&&S.beginShadows();const z=d.state.shadowsArray;if(M.render(z,b,D),J===!0&&S.endShadows(),this.info.autoReset===!0&&this.info.reset(),G.render(u,b),d.setupLights(x.physicallyCorrectLights),D.isArrayCamera){const N=D.cameras;for(let q=0,Ee=N.length;q<Ee;q++){const Ae=N[q];Ft(u,b,Ae,Ae.viewport)}}else Ft(u,b,D);T!==null&&(k.updateMultisampleRenderTarget(T),k.updateRenderTargetMipmap(T)),b.isScene===!0&&b.onAfterRender(x,b,D),ae.buffers.depth.setTest(!0),ae.buffers.depth.setMask(!0),ae.buffers.color.setMask(!0),ae.setPolygonOffset(!1),pe.resetDefaultState(),y=-1,E=null,g.pop(),g.length>0?d=g[g.length-1]:d=null,p.pop(),p.length>0?u=p[p.length-1]:u=null};function Ke(b,D,z,N){if(b.visible===!1)return;if(b.layers.test(D.layers)){if(b.isGroup)z=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(D);else if(b.isLight)d.pushLight(b),b.castShadow&&d.pushShadow(b);else if(b.isSprite){if(!b.frustumCulled||H.intersectsSprite(b)){N&&ie.setFromMatrixPosition(b.matrixWorld).applyMatrix4(X);const Ae=ye.update(b),Re=b.material;Re.visible&&u.push(b,Ae,Re,z,ie.z,null)}}else if((b.isMesh||b.isLine||b.isPoints)&&(b.isSkinnedMesh&&b.skeleton.frame!==Ce.render.frame&&(b.skeleton.update(),b.skeleton.frame=Ce.render.frame),!b.frustumCulled||H.intersectsObject(b))){N&&ie.setFromMatrixPosition(b.matrixWorld).applyMatrix4(X);const Ae=ye.update(b),Re=b.material;if(Array.isArray(Re)){const Le=Ae.groups;for(let Oe=0,Fe=Le.length;Oe<Fe;Oe++){const Ne=Le[Oe],Qe=Re[Ne.materialIndex];Qe&&Qe.visible&&u.push(b,Ae,Qe,z,ie.z,Ne)}}else Re.visible&&u.push(b,Ae,Re,z,ie.z,null)}}const Ee=b.children;for(let Ae=0,Re=Ee.length;Ae<Re;Ae++)Ke(Ee[Ae],D,z,N)}function Ft(b,D,z,N){const q=b.opaque,Ee=b.transmissive,Ae=b.transparent;d.setupLightsView(z),Ee.length>0&&kt(q,D,z),N&&ae.viewport(A.copy(N)),q.length>0&&Xi(q,D,z),Ee.length>0&&Xi(Ee,D,z),Ae.length>0&&Xi(Ae,D,z)}function kt(b,D,z){if(U===null){const Ae=o===!0&&be.isWebGL2===!0?Ks:At;U=new Ae(1024,1024,{generateMipmaps:!0,type:xe.convert(ti)!==null?ti:hn,minFilter:zr,magFilter:rt,wrapS:St,wrapT:St,useRenderToTexture:fe.has("WEBGL_multisampled_render_to_texture")})}const N=x.getRenderTarget();x.setRenderTarget(U),x.clear();const q=x.toneMapping;x.toneMapping=cn,Xi(b,D,z),x.toneMapping=q,k.updateMultisampleRenderTarget(U),k.updateRenderTargetMipmap(U),x.setRenderTarget(N)}function Xi(b,D,z){const N=D.isScene===!0?D.overrideMaterial:null;for(let q=0,Ee=b.length;q<Ee;q++){const Ae=b[q],Re=Ae.object,Le=Ae.geometry,Oe=N===null?Ae.material:N,Fe=Ae.group;Re.layers.test(z.layers)&&tc(Re,D,z,Le,Oe,Fe)}}function tc(b,D,z,N,q,Ee){b.onBeforeRender(x,D,z,N,q,Ee),b.modelViewMatrix.multiplyMatrices(z.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),q.onBeforeRender(x,D,z,N,b,Ee),q.transparent===!0&&q.side===si?(q.side=it,q.needsUpdate=!0,x.renderBufferDirect(z,D,N,q,b,Ee),q.side=Di,q.needsUpdate=!0,x.renderBufferDirect(z,D,N,q,b,Ee),q.side=si):x.renderBufferDirect(z,D,N,q,b,Ee),b.onAfterRender(x,D,z,N,q,Ee)}function Xr(b,D,z){D.isScene!==!0&&(D=ue);const N=we.get(b),q=d.state.lights,Ee=d.state.shadowsArray,Ae=q.state.version,Re=Se.getParameters(b,q.state,Ee,D,z),Le=Se.getProgramCacheKey(Re);let Oe=N.programs;N.environment=b.isMeshStandardMaterial?D.environment:null,N.fog=D.fog,N.envMap=(b.isMeshStandardMaterial?$:Q).get(b.envMap||N.environment),Oe===void 0&&(b.addEventListener("dispose",he),Oe=new Map,N.programs=Oe);let Fe=Oe.get(Le);if(Fe!==void 0){if(N.currentProgram===Fe&&N.lightsStateVersion===Ae)return xo(b,Re),Fe}else Re.uniforms=Se.getUniforms(b),b.onBuild(z,Re,x),b.onBeforeCompile(Re,x),Fe=Se.acquireProgram(Re,Le),Oe.set(Le,Fe),N.uniforms=Re.uniforms;const Ne=N.uniforms;(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(Ne.clippingPlanes=S.uniform),xo(b,Re),N.needsLights=rc(b),N.lightsStateVersion=Ae,N.needsLights&&(Ne.ambientLightColor.value=q.state.ambient,Ne.lightProbe.value=q.state.probe,Ne.directionalLights.value=q.state.directional,Ne.directionalLightShadows.value=q.state.directionalShadow,Ne.spotLights.value=q.state.spot,Ne.spotLightShadows.value=q.state.spotShadow,Ne.rectAreaLights.value=q.state.rectArea,Ne.ltc_1.value=q.state.rectAreaLTC1,Ne.ltc_2.value=q.state.rectAreaLTC2,Ne.pointLights.value=q.state.point,Ne.pointLightShadows.value=q.state.pointShadow,Ne.hemisphereLights.value=q.state.hemi,Ne.directionalShadowMap.value=q.state.directionalShadowMap,Ne.directionalShadowMatrix.value=q.state.directionalShadowMatrix,Ne.spotShadowMap.value=q.state.spotShadowMap,Ne.spotShadowMatrix.value=q.state.spotShadowMatrix,Ne.pointShadowMap.value=q.state.pointShadowMap,Ne.pointShadowMatrix.value=q.state.pointShadowMatrix);const Qe=Fe.getUniforms(),vn=dn.seqWithValue(Qe.seq,Ne);return N.currentProgram=Fe,N.uniformsList=vn,Fe}function xo(b,D){const z=we.get(b);z.outputEncoding=D.outputEncoding,z.instancing=D.instancing,z.skinning=D.skinning,z.morphTargets=D.morphTargets,z.morphNormals=D.morphNormals,z.morphTargetsCount=D.morphTargetsCount,z.numClippingPlanes=D.numClippingPlanes,z.numIntersection=D.numClipIntersection,z.vertexAlphas=D.vertexAlphas,z.vertexTangents=D.vertexTangents,z.toneMapping=D.toneMapping}function nc(b,D,z,N,q){D.isScene!==!0&&(D=ue),k.resetTextureUnits();const Ee=D.fog,Ae=N.isMeshStandardMaterial?D.environment:null,Re=T===null?x.outputEncoding:T.isXRRenderTarget===!0?T.texture.encoding:mn,Le=(N.isMeshStandardMaterial?$:Q).get(N.envMap||Ae),Oe=N.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,Fe=!!N.normalMap&&!!z.attributes.tangent,Ne=!!z.morphAttributes.position,Qe=!!z.morphAttributes.normal,vn=z.morphAttributes.position?z.morphAttributes.position.length:0,Rn=N.toneMapped?x.toneMapping:cn,ze=we.get(N),Nt=d.state.lights;if(J===!0&&(ce===!0||b!==E)){const Rt=b===E&&N.id===y;S.setState(N,b,Rt)}let nt=!1;N.version===ze.__version?(ze.needsLights&&ze.lightsStateVersion!==Nt.state.version||ze.outputEncoding!==Re||q.isInstancedMesh&&ze.instancing===!1||!q.isInstancedMesh&&ze.instancing===!0||q.isSkinnedMesh&&ze.skinning===!1||!q.isSkinnedMesh&&ze.skinning===!0||ze.envMap!==Le||N.fog&&ze.fog!==Ee||ze.numClippingPlanes!==void 0&&(ze.numClippingPlanes!==S.numPlanes||ze.numIntersection!==S.numIntersection)||ze.vertexAlphas!==Oe||ze.vertexTangents!==Fe||ze.morphTargets!==Ne||ze.morphNormals!==Qe||ze.toneMapping!==Rn||be.isWebGL2===!0&&ze.morphTargetsCount!==vn)&&(nt=!0):(nt=!0,ze.__version=N.version);let Bt=ze.currentProgram;nt===!0&&(Bt=Xr(N,D,q));let ji=!1,zt=!1,Wt=!1;const ft=Bt.getUniforms(),xi=ze.uniforms;if(ae.useProgram(Bt.program)&&(ji=!0,zt=!0,Wt=!0),N.id!==y&&(y=N.id,zt=!0),ji||E!==b){if(ft.setValue(O,"projectionMatrix",b.projectionMatrix),be.logarithmicDepthBuffer&&ft.setValue(O,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),E!==b&&(E=b,zt=!0,Wt=!0),N.isShaderMaterial||N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshStandardMaterial||N.envMap){const Rt=ft.map.cameraPosition;Rt!==void 0&&Rt.setValue(O,ie.setFromMatrixPosition(b.matrixWorld))}(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&ft.setValue(O,"isOrthographic",b.isOrthographicCamera===!0),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial||N.isShadowMaterial||q.isSkinnedMesh)&&ft.setValue(O,"viewMatrix",b.matrixWorldInverse)}if(q.isSkinnedMesh){ft.setOptional(O,q,"bindMatrix"),ft.setOptional(O,q,"bindMatrixInverse");const Rt=q.skeleton;Rt&&(be.floatVertexTextures?(Rt.boneTexture===null&&Rt.computeBoneTexture(),ft.setValue(O,"boneTexture",Rt.boneTexture,k),ft.setValue(O,"boneTextureSize",Rt.boneTextureSize)):ft.setOptional(O,Rt,"boneMatrices"))}return!!z&&(z.morphAttributes.position!==void 0||z.morphAttributes.normal!==void 0)&&K.update(q,z,N,Bt),(zt||ze.receiveShadow!==q.receiveShadow)&&(ze.receiveShadow=q.receiveShadow,ft.setValue(O,"receiveShadow",q.receiveShadow)),zt&&(ft.setValue(O,"toneMappingExposure",x.toneMappingExposure),ze.needsLights&&ic(xi,Wt),Ee&&N.fog&&Ie.refreshFogUniforms(xi,Ee),Ie.refreshMaterialUniforms(xi,N,_,Y,U),dn.upload(O,ze.uniformsList,xi,k)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(dn.upload(O,ze.uniformsList,xi,k),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&ft.setValue(O,"center",q.center),ft.setValue(O,"modelViewMatrix",q.modelViewMatrix),ft.setValue(O,"normalMatrix",q.normalMatrix),ft.setValue(O,"modelMatrix",q.matrixWorld),Bt}function ic(b,D){b.ambientLightColor.needsUpdate=D,b.lightProbe.needsUpdate=D,b.directionalLights.needsUpdate=D,b.directionalLightShadows.needsUpdate=D,b.pointLights.needsUpdate=D,b.pointLightShadows.needsUpdate=D,b.spotLights.needsUpdate=D,b.spotLightShadows.needsUpdate=D,b.rectAreaLights.needsUpdate=D,b.hemisphereLights.needsUpdate=D}function rc(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return m},this.getActiveMipmapLevel=function(){return f},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(b,D,z){we.get(b.texture).__webglTexture=D,we.get(b.depthTexture).__webglTexture=z;const N=we.get(b);N.__hasExternalTextures=!0,N.__hasExternalTextures&&(N.__autoAllocateDepthBuffer=z===void 0,N.__autoAllocateDepthBuffer||b.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),b.useRenderToTexture=!1,b.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(b,D){const z=we.get(b);z.__webglFramebuffer=D,z.__useDefaultFramebuffer=D===void 0},this.setRenderTarget=function(b,D=0,z=0){T=b,m=D,f=z;let N=!0;if(b){const Le=we.get(b);Le.__useDefaultFramebuffer!==void 0?(ae.bindFramebuffer(36160,null),N=!1):Le.__webglFramebuffer===void 0?k.setupRenderTarget(b):Le.__hasExternalTextures&&k.rebindTextures(b,we.get(b.texture).__webglTexture,we.get(b.depthTexture).__webglTexture)}let q=null,Ee=!1,Ae=!1;if(b){const Le=b.texture;(Le.isDataTexture3D||Le.isDataTexture2DArray)&&(Ae=!0);const Oe=we.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(q=Oe[D],Ee=!0):b.useRenderbuffer?q=we.get(b).__webglMultisampledFramebuffer:q=Oe,A.copy(b.viewport),L.copy(b.scissor),j=b.scissorTest}else A.copy(B).multiplyScalar(_).floor(),L.copy(F).multiplyScalar(_).floor(),j=I;if(ae.bindFramebuffer(36160,q)&&be.drawBuffers&&N&&ae.drawBuffers(b,q),ae.viewport(A),ae.scissor(L),ae.setScissorTest(j),Ee){const Le=we.get(b.texture);O.framebufferTexture2D(36160,36064,34069+D,Le.__webglTexture,z)}else if(Ae){const Le=we.get(b.texture),Oe=D||0;O.framebufferTextureLayer(36160,36064,Le.__webglTexture,z||0,Oe)}y=-1},this.readRenderTargetPixels=function(b,D,z,N,q,Ee,Ae){if(!(b&&b.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Re=we.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ae!==void 0&&(Re=Re[Ae]),Re){ae.bindFramebuffer(36160,Re);try{const Le=b.texture,Oe=Le.format,Fe=Le.type;if(Oe!==xt&&xe.convert(Oe)!==O.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ne=Fe===ti&&(fe.has("EXT_color_buffer_half_float")||be.isWebGL2&&fe.has("EXT_color_buffer_float"));if(Fe!==hn&&xe.convert(Fe)!==O.getParameter(35738)&&!(Fe===Sn&&(be.isWebGL2||fe.has("OES_texture_float")||fe.has("WEBGL_color_buffer_float")))&&!Ne){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O.checkFramebufferStatus(36160)===36053?D>=0&&D<=b.width-N&&z>=0&&z<=b.height-q&&O.readPixels(D,z,N,q,xe.convert(Oe),xe.convert(Fe),Ee):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const Le=T!==null?we.get(T).__webglFramebuffer:null;ae.bindFramebuffer(36160,Le)}}},this.copyFramebufferToTexture=function(b,D,z=0){if(D.isFramebufferTexture!==!0){console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");return}const N=Math.pow(2,-z),q=Math.floor(D.image.width*N),Ee=Math.floor(D.image.height*N);k.setTexture2D(D,0),O.copyTexSubImage2D(3553,z,0,0,b.x,b.y,q,Ee),ae.unbindTexture()},this.copyTextureToTexture=function(b,D,z,N=0){const q=D.image.width,Ee=D.image.height,Ae=xe.convert(z.format),Re=xe.convert(z.type);k.setTexture2D(z,0),O.pixelStorei(37440,z.flipY),O.pixelStorei(37441,z.premultiplyAlpha),O.pixelStorei(3317,z.unpackAlignment),D.isDataTexture?O.texSubImage2D(3553,N,b.x,b.y,q,Ee,Ae,Re,D.image.data):D.isCompressedTexture?O.compressedTexSubImage2D(3553,N,b.x,b.y,D.mipmaps[0].width,D.mipmaps[0].height,Ae,D.mipmaps[0].data):O.texSubImage2D(3553,N,b.x,b.y,Ae,Re,D.image),N===0&&z.generateMipmaps&&O.generateMipmap(3553),ae.unbindTexture()},this.copyTextureToTexture3D=function(b,D,z,N,q=0){if(x.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ee=b.max.x-b.min.x+1,Ae=b.max.y-b.min.y+1,Re=b.max.z-b.min.z+1,Le=xe.convert(N.format),Oe=xe.convert(N.type);let Fe;if(N.isDataTexture3D)k.setTexture3D(N,0),Fe=32879;else if(N.isDataTexture2DArray)k.setTexture2DArray(N,0),Fe=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}O.pixelStorei(37440,N.flipY),O.pixelStorei(37441,N.premultiplyAlpha),O.pixelStorei(3317,N.unpackAlignment);const Ne=O.getParameter(3314),Qe=O.getParameter(32878),vn=O.getParameter(3316),Rn=O.getParameter(3315),ze=O.getParameter(32877),Nt=z.isCompressedTexture?z.mipmaps[0]:z.image;O.pixelStorei(3314,Nt.width),O.pixelStorei(32878,Nt.height),O.pixelStorei(3316,b.min.x),O.pixelStorei(3315,b.min.y),O.pixelStorei(32877,b.min.z),z.isDataTexture||z.isDataTexture3D?O.texSubImage3D(Fe,q,D.x,D.y,D.z,Ee,Ae,Re,Le,Oe,Nt.data):z.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),O.compressedTexSubImage3D(Fe,q,D.x,D.y,D.z,Ee,Ae,Re,Le,Nt.data)):O.texSubImage3D(Fe,q,D.x,D.y,D.z,Ee,Ae,Re,Le,Oe,Nt),O.pixelStorei(3314,Ne),O.pixelStorei(32878,Qe),O.pixelStorei(3316,vn),O.pixelStorei(3315,Rn),O.pixelStorei(32877,ze),q===0&&N.generateMipmaps&&O.generateMipmap(Fe),ae.unbindTexture()},this.initTexture=function(b){k.setTexture2D(b,0),ae.unbindTexture()},this.resetState=function(){m=0,f=0,T=null,ae.reset(),pe.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Ve.prototype.isWebGLRenderer=!0;class Yp extends Ve{}Yp.prototype.isWebGL1Renderer=!0;class oo extends Ue{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}oo.prototype.isScene=!0;class Wi{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Fi,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Ht()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ht()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ht()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}Wi.prototype.isInterleavedBuffer=!0;const et=new w;class Bi{constructor(e,t,n,i=!1){this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)et.x=this.getX(t),et.y=this.getY(t),et.z=this.getZ(t),et.applyMatrix4(e),this.setXYZ(t,et.x,et.y,et.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)et.x=this.getX(t),et.y=this.getY(t),et.z=this.getZ(t),et.applyNormalMatrix(e),this.setXYZ(t,et.x,et.y,et.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)et.x=this.getX(t),et.y=this.getY(t),et.z=this.getZ(t),et.transformDirection(e),this.setXYZ(t,et.x,et.y,et.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new ot(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Bi(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}Bi.prototype.isInterleavedBufferAttribute=!0;class Rl extends ct{constructor(e){super(),this.type="SpriteMaterial",this.color=new me(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}Rl.prototype.isSpriteMaterial=!0;let Xn;const bi=new w,jn=new w,Yn=new w,Jn=new Z,wi=new Z,Pl=new ve,pr=new w,Si=new w,mr=new w,La=new Z,Ts=new Z,Ra=new Z;class Jp extends Ue{constructor(e){if(super(),this.type="Sprite",Xn===void 0){Xn=new Xe;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Wi(t,5);Xn.setIndex([0,1,2,0,2,3]),Xn.setAttribute("position",new Bi(n,3,0,!1)),Xn.setAttribute("uv",new Bi(n,2,3,!1))}this.geometry=Xn,this.material=e!==void 0?e:new Rl,this.center=new Z(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),jn.setFromMatrixScale(this.matrixWorld),Pl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Yn.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&jn.multiplyScalar(-Yn.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;gr(pr.set(-.5,-.5,0),Yn,o,jn,i,r),gr(Si.set(.5,-.5,0),Yn,o,jn,i,r),gr(mr.set(.5,.5,0),Yn,o,jn,i,r),La.set(0,0),Ts.set(1,0),Ra.set(1,1);let a=e.ray.intersectTriangle(pr,Si,mr,!1,bi);if(a===null&&(gr(Si.set(-.5,.5,0),Yn,o,jn,i,r),Ts.set(0,1),a=e.ray.intersectTriangle(pr,mr,Si,!1,bi),a===null))return;const c=e.ray.origin.distanceTo(bi);c<e.near||c>e.far||t.push({distance:c,point:bi.clone(),uv:tt.getUV(bi,pr,Si,mr,La,Ts,Ra,new Z),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}Jp.prototype.isSprite=!0;function gr(s,e,t,n,i,r){Jn.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(wi.x=r*Jn.x-i*Jn.y,wi.y=i*Jn.x+r*Jn.y):wi.copy(Jn),s.copy(e),s.x+=wi.x,s.y+=wi.y,s.applyMatrix4(Pl)}const Pa=new w,Da=new ke,Ia=new ke,Zp=new w,Fa=new ve;class Dl extends st{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ve,this.bindMatrixInverse=new ve}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new ke,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.x=t.getX(n),e.y=t.getY(n),e.z=t.getZ(n),e.w=t.getW(n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const n=this.skeleton,i=this.geometry;Da.fromBufferAttribute(i.attributes.skinIndex,e),Ia.fromBufferAttribute(i.attributes.skinWeight,e),Pa.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=Ia.getComponent(r);if(o!==0){const a=Da.getComponent(r);Fa.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(Zp.copy(Pa).applyMatrix4(Fa),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}Dl.prototype.isSkinnedMesh=!0;class $p extends Ue{constructor(){super(),this.type="Bone"}}$p.prototype.isBone=!0;class Kp extends lt{constructor(e=null,t=1,n=1,i,r,o,a,c,l=rt,h=rt,u,d){super(null,o,a,c,l,h,i,r,u,d),this.image={data:e,width:t,height:n},this.magFilter=l,this.minFilter=h,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}Kp.prototype.isDataTexture=!0;class ks extends ot{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}ks.prototype.isInstancedBufferAttribute=!0;const Na=new ve,Ba=new ve,xr=[],Ei=new st;class Qp extends st{constructor(e,t,n){super(e,t),this.instanceMatrix=new ks(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Ei.geometry=this.geometry,Ei.material=this.material,Ei.material!==void 0)for(let r=0;r<i;r++){this.getMatrixAt(r,Na),Ba.multiplyMatrices(n,Na),Ei.matrixWorld=Ba,Ei.raycast(e,xr);for(let o=0,a=xr.length;o<a;o++){const c=xr[o];c.instanceId=r,c.object=this,t.push(c)}xr.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ks(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}Qp.prototype.isInstancedMesh=!0;class fn extends ct{constructor(e){super(),this.type="LineBasicMaterial",this.color=new me(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this}}fn.prototype.isLineBasicMaterial=!0;const za=new w,Ua=new w,Oa=new ve,As=new ui,_r=new hi;class ao extends Ue{constructor(e=new Xe,t=new fn){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)za.fromBufferAttribute(t,i-1),Ua.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=za.distanceTo(Ua);e.setAttribute("lineDistance",new Je(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),_r.copy(n.boundingSphere),_r.applyMatrix4(i),_r.radius+=r,e.ray.intersectsSphere(_r)===!1)return;Oa.copy(i).invert(),As.copy(e.ray).applyMatrix4(Oa);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new w,h=new w,u=new w,d=new w,p=this.isLineSegments?2:1;if(n.isBufferGeometry){const g=n.index,v=n.attributes.position;if(g!==null){const m=Math.max(0,o.start),f=Math.min(g.count,o.start+o.count);for(let T=m,y=f-1;T<y;T+=p){const E=g.getX(T),A=g.getX(T+1);if(l.fromBufferAttribute(v,E),h.fromBufferAttribute(v,A),As.distanceSqToSegment(l,h,d,u)>c)continue;d.applyMatrix4(this.matrixWorld);const j=e.ray.origin.distanceTo(d);j<e.near||j>e.far||t.push({distance:j,point:u.clone().applyMatrix4(this.matrixWorld),index:T,face:null,faceIndex:null,object:this})}}else{const m=Math.max(0,o.start),f=Math.min(v.count,o.start+o.count);for(let T=m,y=f-1;T<y;T+=p){if(l.fromBufferAttribute(v,T),h.fromBufferAttribute(v,T+1),As.distanceSqToSegment(l,h,d,u)>c)continue;d.applyMatrix4(this.matrixWorld);const A=e.ray.origin.distanceTo(d);A<e.near||A>e.far||t.push({distance:A,point:u.clone().applyMatrix4(this.matrixWorld),index:T,face:null,faceIndex:null,object:this})}}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}ao.prototype.isLine=!0;const Ha=new w,Va=new w;class zi extends ao{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Ha.fromBufferAttribute(t,i),Va.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Ha.distanceTo(Va);e.setAttribute("lineDistance",new Je(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}zi.prototype.isLineSegments=!0;class em extends ao{constructor(e,t){super(e,t),this.type="LineLoop"}}em.prototype.isLineLoop=!0;class Qn extends ct{constructor(e){super(),this.type="PointsMaterial",this.color=new me(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!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}}Qn.prototype.isPointsMaterial=!0;const Ga=new ve,Ws=new ui,vr=new hi,yr=new w;class Cr extends Ue{constructor(e=new Xe,t=new Qn){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),vr.copy(n.boundingSphere),vr.applyMatrix4(i),vr.radius+=r,e.ray.intersectsSphere(vr)===!1)return;Ga.copy(i).invert(),Ws.copy(e.ray).applyMatrix4(Ga);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a;if(n.isBufferGeometry){const l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let g=d,x=p;g<x;g++){const v=l.getX(g);yr.fromBufferAttribute(u,v),ka(yr,v,c,i,e,t,this)}}else{const d=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let g=d,x=p;g<x;g++)yr.fromBufferAttribute(u,g),ka(yr,g,c,i,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Cr.prototype.isPoints=!0;function ka(s,e,t,n,i,r,o){const a=Ws.distanceSqToPoint(s);if(a<t){const c=new w;Ws.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}class Il extends lt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.minFilter=o!==void 0?o:ut,this.magFilter=r!==void 0?r:ut,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Il.prototype.isVideoTexture=!0;class tm extends lt{constructor(e,t,n){super({width:e,height:t}),this.format=n,this.magFilter=rt,this.minFilter=rt,this.generateMipmaps=!1,this.needsUpdate=!0}}tm.prototype.isFramebufferTexture=!0;class nm extends lt{constructor(e,t,n,i,r,o,a,c,l,h,u,d){super(null,o,a,c,l,h,i,r,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}nm.prototype.isCompressedTexture=!0;class im extends lt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.needsUpdate=!0}}im.prototype.isCanvasTexture=!0;new w;new w;new w;new tt;class Ct{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let o;t?o=t:o=e*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);const h=n[i],d=n[i+1]-h,p=(o-h)/d;return(i+p)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),c=t||(o.isVector2?new Z:new w);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new w,i=[],r=[],o=[],a=new w,c=new ve;for(let p=0;p<=e;p++){const g=p/e;i[p]=this.getTangentAt(g,new w)}r[0]=new w,o[0]=new w;let l=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const g=Math.acos(wt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(c.makeRotationAxis(a,g))}o[p].crossVectors(i[p],r[p])}if(t===!0){let p=Math.acos(wt(r[0].dot(r[e]),-1,1));p/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(p=-p);for(let g=1;g<=e;g++)r[g].applyMatrix4(c.makeRotationAxis(i[g],p*g)),o[g].crossVectors(i[g],r[g])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gr extends Ct{constructor(e=0,t=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t){const n=t||new Z,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);const a=this.aStartAngle+e*r;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=c-this.aX,p=l-this.aY;c=d*h-p*u+this.aX,l=d*u+p*h+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}Gr.prototype.isEllipseCurve=!0;class Fl extends Gr{constructor(e,t,n,i,r,o){super(e,t,n,n,i,r,o),this.type="ArcCurve"}}Fl.prototype.isArcCurve=!0;function lo(){let s=0,e=0,t=0,n=0;function i(r,o,a,c){s=r,e=a,t=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,h,u){let d=(o-r)/l-(a-r)/(l+h)+(a-o)/h,p=(a-o)/h-(c-o)/(h+u)+(c-a)/u;d*=h,p*=h,i(o,a,d,p)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+n*a}}}const Mr=new w,Cs=new lo,Ls=new lo,Rs=new lo;class Nl extends Ct{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new w){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,h;this.closed||a>0?l=i[(a-1)%r]:(Mr.subVectors(i[0],i[1]).add(i[0]),l=Mr);const u=i[a%r],d=i[(a+1)%r];if(this.closed||a+2<r?h=i[(a+2)%r]:(Mr.subVectors(i[r-1],i[r-2]).add(i[r-1]),h=Mr),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let g=Math.pow(l.distanceToSquared(u),p),x=Math.pow(u.distanceToSquared(d),p),v=Math.pow(d.distanceToSquared(h),p);x<1e-4&&(x=1),g<1e-4&&(g=x),v<1e-4&&(v=x),Cs.initNonuniformCatmullRom(l.x,u.x,d.x,h.x,g,x,v),Ls.initNonuniformCatmullRom(l.y,u.y,d.y,h.y,g,x,v),Rs.initNonuniformCatmullRom(l.z,u.z,d.z,h.z,g,x,v)}else this.curveType==="catmullrom"&&(Cs.initCatmullRom(l.x,u.x,d.x,h.x,this.tension),Ls.initCatmullRom(l.y,u.y,d.y,h.y,this.tension),Rs.initCatmullRom(l.z,u.z,d.z,h.z,this.tension));return n.set(Cs.calc(c),Ls.calc(c),Rs.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new w().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}Nl.prototype.isCatmullRomCurve3=!0;function Wa(s,e,t,n,i){const r=(n-e)*.5,o=(i-t)*.5,a=s*s,c=s*a;return(2*t-2*n+r+o)*c+(-3*t+3*n-2*r-o)*a+r*s+t}function rm(s,e){const t=1-s;return t*t*e}function sm(s,e){return 2*(1-s)*s*e}function om(s,e){return s*s*e}function Ri(s,e,t,n){return rm(s,e)+sm(s,t)+om(s,n)}function am(s,e){const t=1-s;return t*t*t*e}function lm(s,e){const t=1-s;return 3*t*t*s*e}function cm(s,e){return 3*(1-s)*s*s*e}function hm(s,e){return s*s*s*e}function Pi(s,e,t,n,i){return am(s,e)+lm(s,t)+cm(s,n)+hm(s,i)}class co extends Ct{constructor(e=new Z,t=new Z,n=new Z,i=new Z){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new Z){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Pi(e,i.x,r.x,o.x,a.x),Pi(e,i.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}co.prototype.isCubicBezierCurve=!0;class Bl extends Ct{constructor(e=new w,t=new w,n=new w,i=new w){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new w){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Pi(e,i.x,r.x,o.x,a.x),Pi(e,i.y,r.y,o.y,a.y),Pi(e,i.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}Bl.prototype.isCubicBezierCurve3=!0;class kr extends Ct{constructor(e=new Z,t=new Z){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Z){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const n=t||new Z;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}kr.prototype.isLineCurve=!0;class um extends Ct{constructor(e=new w,t=new w){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new w){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ho extends Ct{constructor(e=new Z,t=new Z,n=new Z){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Z){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Ri(e,i.x,r.x,o.x),Ri(e,i.y,r.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}ho.prototype.isQuadraticBezierCurve=!0;class zl extends Ct{constructor(e=new w,t=new w,n=new w){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new w){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Ri(e,i.x,r.x,o.x),Ri(e,i.y,r.y,o.y),Ri(e,i.z,r.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}zl.prototype.isQuadraticBezierCurve3=!0;class uo extends Ct{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new Z){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(Wa(a,c.x,l.x,h.x,u.x),Wa(a,c.y,l.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new Z().fromArray(i))}return this}}uo.prototype.isSplineCurve=!0;var Ul=Object.freeze({__proto__:null,ArcCurve:Fl,CatmullRomCurve3:Nl,CubicBezierCurve:co,CubicBezierCurve3:Bl,EllipseCurve:Gr,LineCurve:kr,LineCurve3:um,QuadraticBezierCurve:ho,QuadraticBezierCurve3:zl,SplineCurve:uo});class dm extends Ct{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new kr(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const o=i[r]-n,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],a=o&&o.isEllipseCurve?e*2:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){const h=c[l];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new Ul[i.type]().fromJSON(i))}return this}}class qs extends dm{constructor(e){super(),this.type="Path",this.currentPoint=new Z,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new kr(this.currentPoint.clone(),new Z(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new ho(this.currentPoint.clone(),new Z(e,t),new Z(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,o){const a=new co(this.currentPoint.clone(),new Z(e,t),new Z(n,i),new Z(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new uo(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,i,r,o),this}absarc(e,t,n,i,r,o){return this.absellipse(e,t,n,n,i,r,o),this}ellipse(e,t,n,i,r,o,a,c){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,n,i,r,o,a,c),this}absellipse(e,t,n,i,r,o,a,c){const l=new Gr(e,t,n,i,r,o,a,c);if(this.curves.length>0){const u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);const h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class fi extends qs{constructor(e){super(e),this.uuid=Ht(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new qs().fromJSON(i))}return this}}const fm={triangulate:function(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=Ol(s,0,i,t,!0);const o=[];if(!r||r.next===r.prev)return o;let a,c,l,h,u,d,p;if(n&&(r=_m(s,e,r,t)),s.length>80*t){a=l=s[0],c=h=s[1];for(let g=t;g<i;g+=t)u=s[g],d=s[g+1],u<a&&(a=u),d<c&&(c=d),u>l&&(l=u),d>h&&(h=d);p=Math.max(l-a,h-c),p=p!==0?1/p:0}return Ui(r,o,t,a,c,p),o}};function Ol(s,e,t,n,i){let r,o;if(i===Lm(s,e,t,n)>0)for(r=e;r<t;r+=n)o=qa(r,s[r],s[r+1],o);else for(r=t-n;r>=e;r-=n)o=qa(r,s[r],s[r+1],o);return o&&Wr(o,o.next)&&(Hi(o),o=o.next),o}function xn(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(Wr(t,t.next)||$e(t.prev,t,t.next)===0)){if(Hi(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Ui(s,e,t,n,i,r,o){if(!s)return;!o&&r&&wm(s,n,i,r);let a=s,c,l;for(;s.prev!==s.next;){if(c=s.prev,l=s.next,r?mm(s,n,i,r):pm(s)){e.push(c.i/t),e.push(s.i/t),e.push(l.i/t),Hi(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=gm(xn(s),e,t),Ui(s,e,t,n,i,r,2)):o===2&&xm(s,e,t,n,i,r):Ui(xn(s),e,t,n,i,r,1);break}}}function pm(s){const e=s.prev,t=s,n=s.next;if($e(e,t,n)>=0)return!1;let i=s.next.next;for(;i!==s.prev;){if(ei(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&$e(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function mm(s,e,t,n){const i=s.prev,r=s,o=s.next;if($e(i,r,o)>=0)return!1;const a=i.x<r.x?i.x<o.x?i.x:o.x:r.x<o.x?r.x:o.x,c=i.y<r.y?i.y<o.y?i.y:o.y:r.y<o.y?r.y:o.y,l=i.x>r.x?i.x>o.x?i.x:o.x:r.x>o.x?r.x:o.x,h=i.y>r.y?i.y>o.y?i.y:o.y:r.y>o.y?r.y:o.y,u=Xs(a,c,e,t,n),d=Xs(l,h,e,t,n);let p=s.prevZ,g=s.nextZ;for(;p&&p.z>=u&&g&&g.z<=d;){if(p!==s.prev&&p!==s.next&&ei(i.x,i.y,r.x,r.y,o.x,o.y,p.x,p.y)&&$e(p.prev,p,p.next)>=0||(p=p.prevZ,g!==s.prev&&g!==s.next&&ei(i.x,i.y,r.x,r.y,o.x,o.y,g.x,g.y)&&$e(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;p&&p.z>=u;){if(p!==s.prev&&p!==s.next&&ei(i.x,i.y,r.x,r.y,o.x,o.y,p.x,p.y)&&$e(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;g&&g.z<=d;){if(g!==s.prev&&g!==s.next&&ei(i.x,i.y,r.x,r.y,o.x,o.y,g.x,g.y)&&$e(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function gm(s,e,t){let n=s;do{const i=n.prev,r=n.next.next;!Wr(i,r)&&Hl(i,n,n.next,r)&&Oi(i,r)&&Oi(r,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(r.i/t),Hi(n),Hi(n.next),n=s=r),n=n.next}while(n!==s);return xn(n)}function xm(s,e,t,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Tm(o,a)){let c=Vl(o,a);o=xn(o,o.next),c=xn(c,c.next),Ui(o,e,t,n,i,r),Ui(c,e,t,n,i,r);return}a=a.next}o=o.next}while(o!==s)}function _m(s,e,t,n){const i=[];let r,o,a,c,l;for(r=0,o=e.length;r<o;r++)a=e[r]*n,c=r<o-1?e[r+1]*n:s.length,l=Ol(s,a,c,n,!1),l===l.next&&(l.steiner=!0),i.push(Em(l));for(i.sort(vm),r=0;r<i.length;r++)ym(i[r],t),t=xn(t,t.next);return t}function vm(s,e){return s.x-e.x}function ym(s,e){if(e=Mm(s,e),e){const t=Vl(e,s);xn(e,e.next),xn(t,t.next)}}function Mm(s,e){let t=e;const n=s.x,i=s.y;let r=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>r){if(r=d,d===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===r)return o;const a=o,c=o.x,l=o.y;let h=1/0,u;t=o;do n>=t.x&&t.x>=c&&n!==t.x&&ei(i<l?n:r,i,c,l,i<l?r:n,i,t.x,t.y)&&(u=Math.abs(i-t.y)/(n-t.x),Oi(t,s)&&(u<h||u===h&&(t.x>o.x||t.x===o.x&&bm(o,t)))&&(o=t,h=u)),t=t.next;while(t!==a);return o}function bm(s,e){return $e(s.prev,s,e.prev)<0&&$e(e.next,s,s.next)<0}function wm(s,e,t,n){let i=s;do i.z===null&&(i.z=Xs(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Sm(i)}function Sm(s){let e,t,n,i,r,o,a,c,l=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;t=n}r.nextZ=null,l*=2}while(o>1);return s}function Xs(s,e,t,n,i){return s=32767*(s-t)*i,e=32767*(e-n)*i,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function Em(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function ei(s,e,t,n,i,r,o,a){return(i-o)*(e-a)-(s-o)*(r-a)>=0&&(s-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(r-a)-(i-o)*(n-a)>=0}function Tm(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!Am(s,e)&&(Oi(s,e)&&Oi(e,s)&&Cm(s,e)&&($e(s.prev,s,e.prev)||$e(s,e.prev,e))||Wr(s,e)&&$e(s.prev,s,s.next)>0&&$e(e.prev,e,e.next)>0)}function $e(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Wr(s,e){return s.x===e.x&&s.y===e.y}function Hl(s,e,t,n){const i=wr($e(s,e,t)),r=wr($e(s,e,n)),o=wr($e(t,n,s)),a=wr($e(t,n,e));return!!(i!==r&&o!==a||i===0&&br(s,t,e)||r===0&&br(s,n,e)||o===0&&br(t,s,n)||a===0&&br(t,e,n))}function br(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function wr(s){return s>0?1:s<0?-1:0}function Am(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&Hl(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Oi(s,e){return $e(s.prev,s,s.next)<0?$e(s,e,s.next)>=0&&$e(s,s.prev,e)>=0:$e(s,e,s.prev)<0||$e(s,s.next,e)<0}function Cm(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function Vl(s,e){const t=new js(s.i,s.x,s.y),n=new js(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function qa(s,e,t,n){const i=new js(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Hi(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function js(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Lm(s,e,t,n){let i=0;for(let r=e,o=t-n;r<t;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}class pn{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return pn.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];Xa(e),ja(n,e);let o=e.length;t.forEach(Xa);for(let c=0;c<t.length;c++)i.push(o),o+=t[c].length,ja(n,t[c]);const a=fm.triangulate(n,i);for(let c=0;c<a.length;c+=3)r.push(a.slice(c,c+3));return r}}function Xa(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function ja(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class pi extends Xe{constructor(e=new fi([new Z(.5,.5),new Z(-.5,.5),new Z(-.5,-.5),new Z(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a];o(l)}this.setAttribute("position",new Je(i,3)),this.setAttribute("uv",new Je(r,2)),this.computeVertexNormals();function o(a){const c=[],l=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1;let u=t.depth!==void 0?t.depth:1,d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:p-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,v=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,f=t.UVGenerator!==void 0?t.UVGenerator:Rm;t.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),u=t.amount);let T,y=!1,E,A,L,j;m&&(T=m.getSpacedPoints(h),y=!0,d=!1,E=m.computeFrenetFrames(h,!1),A=new w,L=new w,j=new w),d||(v=0,p=0,g=0,x=0);const te=a.extractPoints(l);let Y=te.shape;const _=te.holes;if(!pn.isClockWise(Y)){Y=Y.reverse();for(let k=0,Q=_.length;k<Q;k++){const $=_[k];pn.isClockWise($)&&(_[k]=$.reverse())}}const P=pn.triangulateShape(Y,_),B=Y;for(let k=0,Q=_.length;k<Q;k++){const $=_[k];Y=Y.concat($)}function F(k,Q,$){return Q||console.error("THREE.ExtrudeGeometry: vec does not exist"),Q.clone().multiplyScalar($).add(k)}const I=Y.length,H=P.length;function J(k,Q,$){let le,se,ye;const Se=k.x-Q.x,Ie=k.y-Q.y,We=$.x-k.x,Ge=$.y-k.y,S=Se*Se+Ie*Ie,M=Se*Ge-Ie*We;if(Math.abs(M)>Number.EPSILON){const G=Math.sqrt(S),K=Math.sqrt(We*We+Ge*Ge),de=Q.x-Ie/G,V=Q.y+Se/G,xe=$.x-Ge/K,pe=$.y+We/K,re=((xe-de)*Ge-(pe-V)*We)/(Se*Ge-Ie*We);le=de+Se*re-k.x,se=V+Ie*re-k.y;const ne=le*le+se*se;if(ne<=2)return new Z(le,se);ye=Math.sqrt(ne/2)}else{let G=!1;Se>Number.EPSILON?We>Number.EPSILON&&(G=!0):Se<-Number.EPSILON?We<-Number.EPSILON&&(G=!0):Math.sign(Ie)===Math.sign(Ge)&&(G=!0),G?(le=-Ie,se=Se,ye=Math.sqrt(S)):(le=Se,se=Ie,ye=Math.sqrt(S/2))}return new Z(le/ye,se/ye)}const ce=[];for(let k=0,Q=B.length,$=Q-1,le=k+1;k<Q;k++,$++,le++)$===Q&&($=0),le===Q&&(le=0),ce[k]=J(B[k],B[$],B[le]);const U=[];let X,ie=ce.concat();for(let k=0,Q=_.length;k<Q;k++){const $=_[k];X=[];for(let le=0,se=$.length,ye=se-1,Se=le+1;le<se;le++,ye++,Se++)ye===se&&(ye=0),Se===se&&(Se=0),X[le]=J($[le],$[ye],$[Se]);U.push(X),ie=ie.concat(X)}for(let k=0;k<v;k++){const Q=k/v,$=p*Math.cos(Q*Math.PI/2),le=g*Math.sin(Q*Math.PI/2)+x;for(let se=0,ye=B.length;se<ye;se++){const Se=F(B[se],ce[se],le);fe(Se.x,Se.y,-$)}for(let se=0,ye=_.length;se<ye;se++){const Se=_[se];X=U[se];for(let Ie=0,We=Se.length;Ie<We;Ie++){const Ge=F(Se[Ie],X[Ie],le);fe(Ge.x,Ge.y,-$)}}}const ue=g+x;for(let k=0;k<I;k++){const Q=d?F(Y[k],ie[k],ue):Y[k];y?(L.copy(E.normals[0]).multiplyScalar(Q.x),A.copy(E.binormals[0]).multiplyScalar(Q.y),j.copy(T[0]).add(L).add(A),fe(j.x,j.y,j.z)):fe(Q.x,Q.y,0)}for(let k=1;k<=h;k++)for(let Q=0;Q<I;Q++){const $=d?F(Y[Q],ie[Q],ue):Y[Q];y?(L.copy(E.normals[k]).multiplyScalar($.x),A.copy(E.binormals[k]).multiplyScalar($.y),j.copy(T[k]).add(L).add(A),fe(j.x,j.y,j.z)):fe($.x,$.y,u/h*k)}for(let k=v-1;k>=0;k--){const Q=k/v,$=p*Math.cos(Q*Math.PI/2),le=g*Math.sin(Q*Math.PI/2)+x;for(let se=0,ye=B.length;se<ye;se++){const Se=F(B[se],ce[se],le);fe(Se.x,Se.y,u+$)}for(let se=0,ye=_.length;se<ye;se++){const Se=_[se];X=U[se];for(let Ie=0,We=Se.length;Ie<We;Ie++){const Ge=F(Se[Ie],X[Ie],le);y?fe(Ge.x,Ge.y+T[h-1].y,T[h-1].x+$):fe(Ge.x,Ge.y,u+$)}}}ge(),O();function ge(){const k=i.length/3;if(d){let Q=0,$=I*Q;for(let le=0;le<H;le++){const se=P[le];be(se[2]+$,se[1]+$,se[0]+$)}Q=h+v*2,$=I*Q;for(let le=0;le<H;le++){const se=P[le];be(se[0]+$,se[1]+$,se[2]+$)}}else{for(let Q=0;Q<H;Q++){const $=P[Q];be($[2],$[1],$[0])}for(let Q=0;Q<H;Q++){const $=P[Q];be($[0]+I*h,$[1]+I*h,$[2]+I*h)}}n.addGroup(k,i.length/3-k,0)}function O(){const k=i.length/3;let Q=0;Be(B,Q),Q+=B.length;for(let $=0,le=_.length;$<le;$++){const se=_[$];Be(se,Q),Q+=se.length}n.addGroup(k,i.length/3-k,1)}function Be(k,Q){let $=k.length;for(;--$>=0;){const le=$;let se=$-1;se<0&&(se=k.length-1);for(let ye=0,Se=h+v*2;ye<Se;ye++){const Ie=I*ye,We=I*(ye+1),Ge=Q+le+Ie,S=Q+se+Ie,M=Q+se+We,G=Q+le+We;ae(Ge,S,M,G)}}}function fe(k,Q,$){c.push(k),c.push(Q),c.push($)}function be(k,Q,$){Ce(k),Ce(Q),Ce($);const le=i.length/3,se=f.generateTopUV(n,i,le-3,le-2,le-1);we(se[0]),we(se[1]),we(se[2])}function ae(k,Q,$,le){Ce(k),Ce(Q),Ce(le),Ce(Q),Ce($),Ce(le);const se=i.length/3,ye=f.generateSideWallUV(n,i,se-6,se-3,se-2,se-1);we(ye[0]),we(ye[1]),we(ye[3]),we(ye[1]),we(ye[2]),we(ye[3])}function Ce(k){i.push(c[k*3+0]),i.push(c[k*3+1]),i.push(c[k*3+2])}function we(k){r.push(k.x),r.push(k.y)}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return Pm(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new Ul[i.type]().fromJSON(i)),new pi(n,e.options)}}const Rm={generateTopUV:function(s,e,t,n,i){const r=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[i*3],h=e[i*3+1];return[new Z(r,o),new Z(a,c),new Z(l,h)]},generateSideWallUV:function(s,e,t,n,i,r){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],h=e[n*3+1],u=e[n*3+2],d=e[i*3],p=e[i*3+1],g=e[i*3+2],x=e[r*3],v=e[r*3+1],m=e[r*3+2];return Math.abs(a-h)<Math.abs(o-l)?[new Z(o,1-c),new Z(l,1-u),new Z(d,1-g),new Z(x,1-m)]:[new Z(a,1-c),new Z(h,1-u),new Z(p,1-g),new Z(v,1-m)]}};function Pm(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const r=s[n];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class qr extends Xe{constructor(e=new fi([new Z(0,.5),new Z(-.5,-.5),new Z(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],o=[];let a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let h=0;h<e.length;h++)l(e[h]),this.addGroup(a,c,h),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Je(i,3)),this.setAttribute("normal",new Je(r,3)),this.setAttribute("uv",new Je(o,2));function l(h){const u=i.length/3,d=h.extractPoints(t);let p=d.shape;const g=d.holes;pn.isClockWise(p)===!1&&(p=p.reverse());for(let v=0,m=g.length;v<m;v++){const f=g[v];pn.isClockWise(f)===!0&&(g[v]=f.reverse())}const x=pn.triangulateShape(p,g);for(let v=0,m=g.length;v<m;v++){const f=g[v];p=p.concat(f)}for(let v=0,m=p.length;v<m;v++){const f=p[v];i.push(f.x,f.y,0),r.push(0,0,1),o.push(f.x,f.y)}for(let v=0,m=x.length;v<m;v++){const f=x[v],T=f[0]+u,y=f[1]+u,E=f[2]+u;n.push(T,y,E),c+=3}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return Dm(t,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const o=t[e.shapes[i]];n.push(o)}return new qr(n,e.curveSegments)}}function Dm(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,n=s.length;t<n;t++){const i=s[t];e.shapes.push(i.uuid)}else e.shapes.push(s.uuid);return e}class Im extends ct{constructor(e){super(),this.type="ShadowMaterial",this.color=new me(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}Im.prototype.isShadowMaterial=!0;class Gl extends ct{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new me(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new me(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ci,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}Gl.prototype.isMeshStandardMaterial=!0;class Fm extends Gl{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Z(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return wt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.sheenColor=new me(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new me(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new me(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}Fm.prototype.isMeshPhysicalMaterial=!0;class kl extends ct{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new me(16777215),this.specular=new me(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new me(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ci,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Nr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}kl.prototype.isMeshPhongMaterial=!0;class Nm extends ct{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new me(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new me(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ci,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Nm.prototype.isMeshToonMaterial=!0;class Bm extends ct{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ci,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}Bm.prototype.isMeshNormalMaterial=!0;class Ys extends ct{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new me(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new me(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Nr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Ys.prototype.isMeshLambertMaterial=!0;class zm extends ct{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new me(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ci,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}zm.prototype.isMeshMatcapMaterial=!0;class Um extends fn{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}Um.prototype.isLineDashedMaterial=!0;const Ye={arraySlice:function(s,e,t){return Ye.isTypedArray(s)?new s.constructor(s.subarray(e,t!==void 0?t:s.length)):s.slice(e,t)},convertArray:function(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)},isTypedArray:function(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)},getKeyframeOrder:function(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){const a=t[r]*e;for(let c=0;c!==e;++c)i[o++]=s[a+c]}return i},flattenJSON:function(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)},subclip:function(s,e,t,n,i=30){const r=s.clone();r.name=e;const o=[];for(let c=0;c<r.tracks.length;++c){const l=r.tracks[c],h=l.getValueSize(),u=[],d=[];for(let p=0;p<l.times.length;++p){const g=l.times[p]*i;if(!(g<t||g>=n)){u.push(l.times[p]);for(let x=0;x<h;++x)d.push(l.values[p*h+x])}}u.length!==0&&(l.times=Ye.convertArray(u,l.times.constructor),l.values=Ye.convertArray(d,l.values.constructor),o.push(l))}r.tracks=o;let a=1/0;for(let c=0;c<r.tracks.length;++c)a>r.tracks[c].times[0]&&(a=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*a);return r.resetDuration(),r},makeClipAdditive:function(s,e=0,t=s,n=30){n<=0&&(n=30);const i=t.tracks.length,r=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;const l=s.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===c});if(l===void 0)continue;let h=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let d=0;const p=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const g=a.times.length-1;let x;if(r<=a.times[0]){const m=h,f=u-h;x=Ye.arraySlice(a.values,m,f)}else if(r>=a.times[g]){const m=g*u+h,f=m+u-h;x=Ye.arraySlice(a.values,m,f)}else{const m=a.createInterpolant(),f=h,T=u-h;m.evaluate(r),x=Ye.arraySlice(m.resultBuffer,f,T)}c==="quaternion"&&new vt().fromArray(x).normalize().conjugate().toArray(x);const v=l.times.length;for(let m=0;m<v;++m){const f=m*p+d;if(c==="quaternion")vt.multiplyQuaternionsFlat(l.values,f,x,0,l.values,f);else{const T=p-d*2;for(let y=0;y<T;++y)l.values[f+y]-=x[y]}}}return s.blendMode=ll,s}};class _n{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){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,e,r)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=r)){const a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,i);if(n===c)break;if(i=r,r=t[--n-1],e>=r)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,i);if(i===void 0)return n=t.length,this._cachedIndex=n,this.afterEnd_(n-1,r,e)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let o=0;o!==i;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}_n.prototype.beforeStart_=_n.prototype.copySampleValue_;_n.prototype.afterEnd_=_n.prototype.copySampleValue_;class Om extends _n{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:$n,endingEnd:$n}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Kn:r=e,a=2*t-n;break;case Pr:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Kn:o=e,c=2*n-t;break;case Pr:o=1,c=n+i[1]-i[0];break;default:o=e-1,c=t}const l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,p=this._weightNext,g=(n-t)/(i-t),x=g*g,v=x*g,m=-d*v+2*d*x-d*g,f=(1+d)*v+(-1.5-2*d)*x+(-.5+d)*g+1,T=(-1-p)*v+(1.5+p)*x+.5*g,y=p*v-p*x;for(let E=0;E!==a;++E)r[E]=m*o[h+E]+f*o[l+E]+T*o[c+E]+y*o[u+E];return r}}class Wl extends _n{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==a;++d)r[d]=o[l+d]*u+o[c+d]*h;return r}}class Hm extends _n{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Gt{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=Ye.convertArray(t,this.TimeBufferType),this.values=Ye.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ye.convertArray(e.times,Array),values:Ye.convertArray(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Hm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Wl(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Om(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Lr:t=this.InterpolantFactoryMethodDiscrete;break;case Rr:t=this.InterpolantFactoryMethodLinear;break;case $r:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Lr;case this.InterpolantFactoryMethodLinear:return Rr;case this.InterpolantFactoryMethodSmooth:return $r}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=Ye.arraySlice(n,r,o),this.values=Ye.arraySlice(this.values,r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(i!==void 0&&Ye.isTypedArray(i))for(let a=0,c=i.length;a!==c;++a){const l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){const e=Ye.arraySlice(this.times),t=Ye.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===$r,r=e.length-1;let o=1;for(let a=1;a<r;++a){let c=!1;const l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(i)c=!0;else{const u=a*n,d=u-n,p=u+n;for(let g=0;g!==n;++g){const x=t[u+g];if(x!==t[d+g]||x!==t[p+g]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];const u=a*n,d=o*n;for(let p=0;p!==n;++p)t[d+p]=t[u+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=Ye.arraySlice(e,0,o),this.values=Ye.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){const e=Ye.arraySlice(this.times,0),t=Ye.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Gt.prototype.TimeBufferType=Float32Array;Gt.prototype.ValueBufferType=Float32Array;Gt.prototype.DefaultInterpolation=Rr;class mi extends Gt{}mi.prototype.ValueTypeName="bool";mi.prototype.ValueBufferType=Array;mi.prototype.DefaultInterpolation=Lr;mi.prototype.InterpolantFactoryMethodLinear=void 0;mi.prototype.InterpolantFactoryMethodSmooth=void 0;class ql extends Gt{}ql.prototype.ValueTypeName="color";class Ir extends Gt{}Ir.prototype.ValueTypeName="number";class Vm extends _n{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t);let l=e*a;for(let h=l+a;l!==h;l+=4)vt.slerpFlat(r,0,o,l-a,o,l,c);return r}}class qi extends Gt{InterpolantFactoryMethodLinear(e){return new Vm(this.times,this.values,this.getValueSize(),e)}}qi.prototype.ValueTypeName="quaternion";qi.prototype.DefaultInterpolation=Rr;qi.prototype.InterpolantFactoryMethodSmooth=void 0;class gi extends Gt{}gi.prototype.ValueTypeName="string";gi.prototype.ValueBufferType=Array;gi.prototype.DefaultInterpolation=Lr;gi.prototype.InterpolantFactoryMethodLinear=void 0;gi.prototype.InterpolantFactoryMethodSmooth=void 0;class Fr extends Gt{}Fr.prototype.ValueTypeName="vector";class Ya{constructor(e,t=-1,n,i=$s){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Ht(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(km(n[o]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(Gt.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);const h=Ye.getKeyframeOrder(c);c=Ye.sortedArray(c,1,h),l=Ye.sortedArray(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new Ir(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){const l=e[a],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,p,g,x){if(p.length!==0){const v=[],m=[];Ye.flattenJSON(p,v,m,g),v.length!==0&&x.push(new u(d,v,m))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const d=l[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let x=0;x<d[g].morphTargets.length;x++)p[d[g].morphTargets[x]]=-1;for(const x in p){const v=[],m=[];for(let f=0;f!==d[g].morphTargets.length;++f){const T=d[g];v.push(T.time),m.push(T.morphTarget===x?1:0)}i.push(new Ir(".morphTargetInfluence["+x+"]",v,m))}c=p.length*(o||1)}else{const p=".bones["+t[u].name+"]";n(Fr,p+".position",d,"pos",i),n(qi,p+".quaternion",d,"rot",i),n(Fr,p+".scale",d,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function Gm(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ir;case"vector":case"vector2":case"vector3":case"vector4":return Fr;case"color":return ql;case"quaternion":return qi;case"bool":case"boolean":return mi;case"string":return gi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function km(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=Gm(s.type);if(s.times===void 0){const t=[],n=[];Ye.flattenJSON(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const li={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Wm{constructor(e,t,n){const i=this;let r=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,r===!1&&i.onStart!==void 0&&i.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const p=l[u],g=l[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return g}return null}}}const qm=new Wm;class Kt{constructor(e){this.manager=e!==void 0?e:qm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}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}}const Zt={};class Xl extends Kt{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=li.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Zt[e]!==void 0){Zt[e].push({onLoad:t,onProgress:n,onError:i});return}Zt[e]=[],Zt[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||l.body.getReader===void 0)return l;const h=Zt[e],u=l.body.getReader(),d=l.headers.get("Content-Length"),p=d?parseInt(d):0,g=p!==0;let x=0;const v=new ReadableStream({start(m){f();function f(){u.read().then(({done:T,value:y})=>{if(T)m.close();else{x+=y.byteLength;const E=new ProgressEvent("progress",{lengthComputable:g,loaded:x,total:p});for(let A=0,L=h.length;A<L;A++){const j=h[A];j.onProgress&&j.onProgress(E)}m.enqueue(y),f()}})}}});return new Response(v)}else throw Error(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return l.arrayBuffer().then(g=>p.decode(g))}}}).then(l=>{li.add(e,l);const h=Zt[e];delete Zt[e];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onLoad&&p.onLoad(l)}}).catch(l=>{const h=Zt[e];if(h===void 0)throw this.manager.itemError(e),l;delete Zt[e];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onError&&p.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class jl extends Kt{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=li.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=Ni("img");function c(){h(),li.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(u){h(),i&&i(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Xm extends Kt{constructor(e){super(e)}load(e,t,n,i){const r=new Ur,o=new jl(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(h){r.images[l]=h,a++,a===6&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}for(let l=0;l<e.length;++l)c(l);return r}}class Yl extends Kt{constructor(e){super(e)}load(e,t,n,i){const r=new lt,o=new jl(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Vt extends Ue{constructor(e,t=1){super(),this.type="Light",this.color=new me(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}Vt.prototype.isLight=!0;class jm extends Vt{constructor(e,t,n){super(e,n),this.type="HemisphereLight",this.position.copy(Ue.DefaultUp),this.updateMatrix(),this.groundColor=new me(t)}copy(e){return Vt.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}jm.prototype.isHemisphereLight=!0;const Ja=new ve,Za=new w,$a=new w;class fo{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Z(512,512),this.map=null,this.mapPass=null,this.matrix=new ve,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Or,this._frameExtents=new Z(1,1),this._viewportCount=1,this._viewports=[new ke(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Za.setFromMatrixPosition(e.matrixWorld),t.position.copy(Za),$a.setFromMatrixPosition(e.target.matrixWorld),t.lookAt($a),t.updateMatrixWorld(),Ja.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ja),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Jl extends fo{constructor(){super(new gt(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,n=Hs*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}Jl.prototype.isSpotLightShadow=!0;class Ym extends Vt{constructor(e,t,n=0,i=Math.PI/3,r=0,o=1){super(e,t),this.type="SpotLight",this.position.copy(Ue.DefaultUp),this.updateMatrix(),this.target=new Ue,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.shadow=new Jl}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}Ym.prototype.isSpotLight=!0;const Ka=new ve,Ti=new w,Ps=new w;class Zl extends fo{constructor(){super(new gt(90,1,.5,500)),this._frameExtents=new Z(4,2),this._viewportCount=6,this._viewports=[new ke(2,1,1,1),new ke(0,1,1,1),new ke(3,1,1,1),new ke(1,1,1,1),new ke(3,0,1,1),new ke(1,0,1,1)],this._cubeDirections=[new w(1,0,0),new w(-1,0,0),new w(0,0,1),new w(0,0,-1),new w(0,1,0),new w(0,-1,0)],this._cubeUps=[new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,1,0),new w(0,0,1),new w(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Ti.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ti),Ps.copy(n.position),Ps.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Ps),n.updateMatrixWorld(),i.makeTranslation(-Ti.x,-Ti.y,-Ti.z),Ka.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ka)}}Zl.prototype.isPointLightShadow=!0;class Jm extends Vt{constructor(e,t,n=0,i=1){super(e,t),this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Zl}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}Jm.prototype.isPointLight=!0;class $l extends fo{constructor(){super(new io(-5,5,5,-5,.5,500))}}$l.prototype.isDirectionalLightShadow=!0;class Kl extends Vt{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy(Ue.DefaultUp),this.updateMatrix(),this.target=new Ue,this.shadow=new $l}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}Kl.prototype.isDirectionalLight=!0;class Zm extends Vt{constructor(e,t){super(e,t),this.type="AmbientLight"}}Zm.prototype.isAmbientLight=!0;class $m extends Vt{constructor(e,t,n=10,i=10){super(e,t),this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}$m.prototype.isRectAreaLight=!0;class Ql{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new w)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*r)),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],1.092548*(n*r)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*r),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],2*.429043*n*r),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}Ql.prototype.isSphericalHarmonics3=!0;class po extends Vt{constructor(e=new Ql,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}po.prototype.isLightProbe=!0;class Km{static decodeText(e){if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Qm extends Xe{constructor(){super(),this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}Qm.prototype.isInstancedBufferGeometry=!0;class eg extends Kt{constructor(e){super(e),typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=li.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){li.add(e,c),t&&t(c),r.manager.itemEnd(e)}).catch(function(c){i&&i(c),r.manager.itemError(e),r.manager.itemEnd(e)}),r.manager.itemStart(e)}}eg.prototype.isImageBitmapLoader=!0;let Sr;const tg={getContext:function(){return Sr===void 0&&(Sr=new(window.AudioContext||window.webkitAudioContext)),Sr},setContext:function(s){Sr=s}};class ng extends Kt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new Xl(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{const c=a.slice(0);tg.getContext().decodeAudioData(c,function(h){t(h)})}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}}class ig extends po{constructor(e,t,n=1){super(void 0,n);const i=new me().set(e),r=new me().set(t),o=new w(i.r,i.g,i.b),a=new w(r.r,r.g,r.b),c=Math.sqrt(Math.PI),l=c*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(a).multiplyScalar(c),this.sh.coefficients[1].copy(o).sub(a).multiplyScalar(l)}}ig.prototype.isHemisphereLightProbe=!0;class rg extends po{constructor(e,t=1){super(void 0,t);const n=new me().set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}}rg.prototype.isAmbientLightProbe=!0;class sg extends Ue{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}class og{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,o;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,r=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(n,i,c,1-r,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,o=i;r!==o;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){vt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const o=this._workIndex*r;vt.multiplyQuaternionsFlat(e,o,e,t,e,n),vt.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const c=t+a;e[c]=e[c]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const mo="\\[\\]\\.:\\/",ag=new RegExp("["+mo+"]","g"),go="[^"+mo+"]",lg="[^"+mo.replace("\\.","")+"]",cg=/((?:WC+[\/:])*)/.source.replace("WC",go),hg=/(WCOD+)?/.source.replace("WCOD",lg),ug=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",go),dg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",go),fg=new RegExp("^"+cg+hg+ug+dg+"$"),pg=["material","materials","bones"];class mg{constructor(e,t,n){const i=n||He.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class He{constructor(e,t,n){this.path=t,this.parsedPath=n||He.parseTrackName(t),this.node=He.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new He.Composite(e,t,n):new He(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(ag,"")}static parseTrackName(e){const t=fg.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);pg.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let o=0;o<r.length;o++){const a=r[o];if(a.name===t||a.uuid===t)return a;const c=n(a.children);if(c)return c}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){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++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){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++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;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=He.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[i];if(o===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(e.geometry.isBufferGeometry){if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}He.Composite=mg;He.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};He.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};He.prototype.GetterByBindingType=[He.prototype._getValue_direct,He.prototype._getValue_array,He.prototype._getValue_arrayElement,He.prototype._getValue_toArray];He.prototype.SetterByBindingTypeAndVersioning=[[He.prototype._setValue_direct,He.prototype._setValue_direct_setNeedsUpdate,He.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[He.prototype._setValue_array,He.prototype._setValue_array_setNeedsUpdate,He.prototype._setValue_array_setMatrixWorldNeedsUpdate],[He.prototype._setValue_arrayElement,He.prototype._setValue_arrayElement_setNeedsUpdate,He.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[He.prototype._setValue_fromArray,He.prototype._setValue_fromArray_setNeedsUpdate,He.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class gg{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),c={endingStart:$n,endingEnd:$n};for(let l=0;l!==o;++l){const h=r[l].createInterpolant(null);a[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=nh,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,r=e._clip.duration,o=r/i,a=i/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const c=a.parameterPositions,l=a.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*n;if(c<0||n===0)return;this._startTime=null,t=n*c}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case ll:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulateAdditive(a);break;case $s:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;n!==null&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const o=n===ih;if(e===0)return r===-1?i:o&&(r&1)===1?t-i:i;if(n===th){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Kn,i.endingEnd=Kn):(e?i.endingStart=this.zeroSlopeAtStart?Kn:$n:i.endingStart=Pr,t?i.endingEnd=this.zeroSlopeAtEnd?Kn:$n:i.endingEnd=Pr)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=r,c[0]=t,a[1]=r+e,c[1]=n,this}}class xg extends Cn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){const d=i[u],p=d.name;let g=h[p];if(g!==void 0)++g.referenceCount,o[u]=g;else{if(g=o[u],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,c,p));continue}const x=t&&t._propertyBindings[u].binding.parsedPath;g=new og(He.create(n,p,x),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,c,p),o[u]=g}a[u].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],c=a.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;const u=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],c.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Wl(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const i=t||this._root,r=i.uuid;let o=typeof e=="string"?Ya.findByName(i,e):e;const a=o!==null?o.uuid:e,c=this._actionsByClip[a];let l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=$s),c!==void 0){const u=c.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;const h=new gg(this,o,t,n);return this._bindAction(h,l),this._addInactiveAction(h,a,r),h}existingAction(e,t){const n=t||this._root,i=n.uuid,r=typeof e=="string"?Ya.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,o);const a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){const o=r.knownActions;for(let a=0,c=o.length;a!==c;++a){const l=o[a];this._deactivateAction(l);const h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(const o in r){const a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}xg.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class _g extends Wi{constructor(e,t,n=1){super(e,t),this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}_g.prototype.isInstancedInterleavedBuffer=!0;const an=new w,Er=new ve,Ds=new ve;class vg extends zi{constructor(e){const t=ec(e),n=new Xe,i=[],r=[],o=new me(0,0,1),a=new me(0,1,0);for(let l=0;l<t.length;l++){const h=t[l];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}n.setAttribute("position",new Je(i,3)),n.setAttribute("color",new Je(r,3));const c=new fn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");Ds.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<t.length;r++){const a=t[r];a.parent&&a.parent.isBone&&(Er.multiplyMatrices(Ds,a.matrixWorld),an.setFromMatrixPosition(Er),i.setXYZ(o,an.x,an.y,an.z),Er.multiplyMatrices(Ds,a.parent.matrixWorld),an.setFromMatrixPosition(Er),i.setXYZ(o+1,an.x,an.y,an.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function ec(s){const e=[];s&&s.isBone&&e.push(s);for(let t=0;t<s.children.length;t++)e.push.apply(e,ec(s.children[t]));return e}class yg extends zi{constructor(e=10,t=10,n=4473924,i=8947848){n=new me(n),i=new me(i);const r=t/2,o=e/t,a=e/2,c=[],l=[];for(let d=0,p=0,g=-a;d<=t;d++,g+=o){c.push(-a,0,g,a,0,g),c.push(g,0,-a,g,0,a);const x=d===r?n:i;x.toArray(l,p),p+=3,x.toArray(l,p),p+=3,x.toArray(l,p),p+=3,x.toArray(l,p),p+=3}const h=new Xe;h.setAttribute("position",new Je(c,3)),h.setAttribute("color",new Je(l,3));const u=new fn({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}}const Mg=new Float32Array(1);new Int32Array(Mg.buffer);Ct.create=function(s,e){return console.log("THREE.Curve.create() has been deprecated"),s.prototype=Object.create(Ct.prototype),s.prototype.constructor=s,s.prototype.getPoint=e,s};qs.prototype.fromPoints=function(s){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(s)};yg.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};vg.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Kt.prototype.extractUrlBase=function(s){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Km.extractUrlBase(s)};Kt.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}};Lt.prototype.center=function(s){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(s)};Lt.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()};Lt.prototype.isIntersectionBox=function(s){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(s)};Lt.prototype.isIntersectionSphere=function(s){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(s)};Lt.prototype.size=function(s){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(s)};hi.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()};Or.prototype.setFromMatrix=function(s){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(s)};dt.prototype.flattenToArrayOffset=function(s,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(s,e)};dt.prototype.multiplyVector3=function(s){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),s.applyMatrix3(this)};dt.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")};dt.prototype.applyToBufferAttribute=function(s){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),s.applyMatrix3(this)};dt.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")};dt.prototype.getInverse=function(s){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(s).invert()};ve.prototype.extractPosition=function(s){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(s)};ve.prototype.flattenToArrayOffset=function(s,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(s,e)};ve.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),new w().setFromMatrixColumn(this,3)};ve.prototype.setRotationFromQuaternion=function(s){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(s)};ve.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")};ve.prototype.multiplyVector3=function(s){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),s.applyMatrix4(this)};ve.prototype.multiplyVector4=function(s){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),s.applyMatrix4(this)};ve.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")};ve.prototype.rotateAxis=function(s){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),s.transformDirection(this)};ve.prototype.crossVector=function(s){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),s.applyMatrix4(this)};ve.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")};ve.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")};ve.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")};ve.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")};ve.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")};ve.prototype.applyToBufferAttribute=function(s){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),s.applyMatrix4(this)};ve.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")};ve.prototype.makeFrustum=function(s,e,t,n,i,r){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(s,e,n,t,i,r)};ve.prototype.getInverse=function(s){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(s).invert()};$t.prototype.isIntersectionLine=function(s){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(s)};vt.prototype.multiplyVector3=function(s){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),s.applyQuaternion(this)};vt.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()};ui.prototype.isIntersectionBox=function(s){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(s)};ui.prototype.isIntersectionPlane=function(s){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(s)};ui.prototype.isIntersectionSphere=function(s){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(s)};tt.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()};tt.prototype.barycoordFromPoint=function(s,e){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(s,e)};tt.prototype.midpoint=function(s){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(s)};tt.prototypenormal=function(s){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(s)};tt.prototype.plane=function(s){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(s)};tt.barycoordFromPoint=function(s,e,t,n,i){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),tt.getBarycoord(s,e,t,n,i)};tt.normal=function(s,e,t,n){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),tt.getNormal(s,e,t,n)};fi.prototype.extractAllPoints=function(s){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(s)};fi.prototype.extrude=function(s){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new pi(this,s)};fi.prototype.makeGeometry=function(s){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new qr(this,s)};Z.prototype.fromAttribute=function(s,e,t){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(s,e,t)};Z.prototype.distanceToManhattan=function(s){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(s)};Z.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};w.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")};w.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")};w.prototype.getPositionFromMatrix=function(s){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(s)};w.prototype.getScaleFromMatrix=function(s){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(s)};w.prototype.getColumnFromMatrix=function(s,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,s)};w.prototype.applyProjection=function(s){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(s)};w.prototype.fromAttribute=function(s,e,t){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(s,e,t)};w.prototype.distanceToManhattan=function(s){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(s)};w.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};ke.prototype.fromAttribute=function(s,e,t){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(s,e,t)};ke.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()};Ue.prototype.getChildByName=function(s){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(s)};Ue.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")};Ue.prototype.translate=function(s,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,s)};Ue.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")};Ue.prototype.applyMatrix=function(s){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(s)};Object.defineProperties(Ue.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(s){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=s}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});st.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")};Object.defineProperties(st.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),rh},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}});Dl.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};gt.prototype.setLens=function(s,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),e!==void 0&&(this.filmGauge=e),this.setFocalLength(s)};Object.defineProperties(Vt.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(s){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=s}},shadowCameraLeft:{set:function(s){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=s}},shadowCameraRight:{set:function(s){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=s}},shadowCameraTop:{set:function(s){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=s}},shadowCameraBottom:{set:function(s){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=s}},shadowCameraNear:{set:function(s){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=s}},shadowCameraFar:{set:function(s){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=s}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(s){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=s}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(s){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=s}},shadowMapHeight:{set:function(s){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=s}}});Object.defineProperties(ot.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===Dr},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(Dr)}}});ot.prototype.setDynamic=function(s){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(s===!0?Dr:Fi),this};ot.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},ot.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")};Xe.prototype.addIndex=function(s){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(s)};Xe.prototype.addAttribute=function(s,e){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),!(e&&e.isBufferAttribute)&&!(e&&e.isInterleavedBufferAttribute)?(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(s,new ot(arguments[1],arguments[2]))):s==="index"?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(e),this):this.setAttribute(s,e)};Xe.prototype.addDrawCall=function(s,e,t){t!==void 0&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(s,e)};Xe.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()};Xe.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")};Xe.prototype.removeAttribute=function(s){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(s)};Xe.prototype.applyMatrix=function(s){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(s)};Object.defineProperties(Xe.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}});Wi.prototype.setDynamic=function(s){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(s===!0?Dr:Fi),this};Wi.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")};pi.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")};pi.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")};pi.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")};oo.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")};Object.defineProperties(ct.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new me}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(s){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=s===rl}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(s){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=s}},vertexTangents:{get:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")},set:function(){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}});Object.defineProperties(An.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(s){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=s}}});Ve.prototype.clearTarget=function(s,e,t,n){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(s),this.clear(e,t,n)};Ve.prototype.animate=function(s){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(s)};Ve.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()};Ve.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()};Ve.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision};Ve.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()};Ve.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")};Ve.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")};Ve.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")};Ve.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")};Ve.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")};Ve.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")};Ve.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures};Ve.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")};Ve.prototype.enableScissorTest=function(s){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(s)};Ve.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")};Ve.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")};Ve.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")};Ve.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")};Ve.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")};Ve.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")};Ve.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")};Ve.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")};Ve.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")};Ve.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()};Object.defineProperties(Ve.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(s){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=s}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(s){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=s}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(s){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=s===!0?je:mn}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}},gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});Object.defineProperties(Cl.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});Object.defineProperties(At.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(s){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=s}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(s){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=s}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(s){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=s}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(s){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=s}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(s){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=s}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(s){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=s}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(s){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=s}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(s){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=s}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(s){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=s}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(s){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=s}}});sg.prototype.load=function(s){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const e=this;return new ng().load(s,function(n){e.setBuffer(n)}),this};to.prototype.updateCubeMap=function(s,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(s,e)};to.prototype.clear=function(s,e,t,n){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(s,e,t,n)};Ln.crossOrigin=void 0;Ln.loadTexture=function(s,e,t,n){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const i=new Yl;i.setCrossOrigin(this.crossOrigin);const r=i.load(s,t,void 0,n);return e&&(r.mapping=e),r};Ln.loadTextureCube=function(s,e,t,n){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const i=new Xm;i.setCrossOrigin(this.crossOrigin);const r=i.load(s,t,void 0,n);return e&&(r.mapping=e),r};Ln.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Ln.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Js}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Js);const bg=/^[og]\s*(.+)?/,wg=/^mtllib /,Sg=/^usemtl /,Eg=/^usemap /,Qa=/\s+/,el=new w,Is=new w,tl=new w,nl=new w,Tt=new w,Tr=new me;function Tg(){const s={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const n=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(i,r){const o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);const a={index:this.materials.length,name:i||"",mtllib:Array.isArray(r)&&r.length>0?r[r.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(c){const l={index:typeof c=="number"?c:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return l.clone=this.clone.bind(l),l}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),i&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),r}},n&&n.name&&typeof n.clone=="function"){const i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){const i=this.vertices,r=this.object.geometry.normals;el.fromArray(i,e),Is.fromArray(i,t),tl.fromArray(i,n),Tt.subVectors(tl,Is),nl.subVectors(el,Is),Tt.cross(nl),Tt.normalize(),r.push(Tt.x,Tt.y,Tt.z),r.push(Tt.x,Tt.y,Tt.z),r.push(Tt.x,Tt.y,Tt.z)},addColor:function(e,t,n){const i=this.colors,r=this.object.geometry.colors;i[e]!==void 0&&r.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&r.push(i[t+0],i[t+1],i[t+2]),i[n]!==void 0&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){const i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,o,a,c,l){const h=this.vertices.length;let u=this.parseVertexIndex(e,h),d=this.parseVertexIndex(t,h),p=this.parseVertexIndex(n,h);if(this.addVertex(u,d,p),this.addColor(u,d,p),a!==void 0&&a!==""){const g=this.normals.length;u=this.parseNormalIndex(a,g),d=this.parseNormalIndex(c,g),p=this.parseNormalIndex(l,g),this.addNormal(u,d,p)}else this.addFaceNormal(u,d,p);if(i!==void 0&&i!==""){const g=this.uvs.length;u=this.parseUVIndex(i,g),d=this.parseUVIndex(r,g),p=this.parseUVIndex(o,g),this.addUV(u,d,p),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,i=e.length;n<i;n++){const r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,i=this.uvs.length;for(let r=0,o=e.length;r<o;r++)this.addVertexLine(this.parseVertexIndex(e[r],n));for(let r=0,o=t.length;r<o;r++)this.addUVLine(this.parseUVIndex(t[r],i))}};return s.startObject("",!1),s}class Ag extends Kt{constructor(e){super(e),this.materials=null}load(e,t,n,i){const r=this,o=new Xl(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Tg;e.indexOf(`\r
|
|
`)!==-1&&(e=e.replace(/\r\n/g,`
|
|
`)),e.indexOf(`\\
|
|
`)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(`
|
|
`);let i=[];for(let a=0,c=n.length;a<c;a++){const l=n[a].trimStart();if(l.length===0)continue;const h=l.charAt(0);if(h!=="#")if(h==="v"){const u=l.split(Qa);switch(u[0]){case"v":t.vertices.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3])),u.length>=7?(Tr.setRGB(parseFloat(u[4]),parseFloat(u[5]),parseFloat(u[6])).convertSRGBToLinear(),t.colors.push(Tr.r,Tr.g,Tr.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));break;case"vt":t.uvs.push(parseFloat(u[1]),parseFloat(u[2]));break}}else if(h==="f"){const d=l.slice(1).trim().split(Qa),p=[];for(let x=0,v=d.length;x<v;x++){const m=d[x];if(m.length>0){const f=m.split("/");p.push(f)}}const g=p[0];for(let x=1,v=p.length-1;x<v;x++){const m=p[x],f=p[x+1];t.addFace(g[0],m[0],f[0],g[1],m[1],f[1],g[2],m[2],f[2])}}else if(h==="l"){const u=l.substring(1).trim().split(" ");let d=[];const p=[];if(l.indexOf("/")===-1)d=u;else for(let g=0,x=u.length;g<x;g++){const v=u[g].split("/");v[0]!==""&&d.push(v[0]),v[1]!==""&&p.push(v[1])}t.addLineGeometry(d,p)}else if(h==="p"){const d=l.slice(1).trim().split(" ");t.addPointGeometry(d)}else if((i=bg.exec(l))!==null){const u=(" "+i[0].slice(1).trim()).slice(1);t.startObject(u)}else if(Sg.test(l))t.object.startMaterial(l.substring(7).trim(),t.materialLibraries);else if(wg.test(l))t.materialLibraries.push(l.substring(7).trim());else if(Eg.test(l))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(h==="s"){if(i=l.split(" "),i.length>1){const d=i[1].trim().toLowerCase();t.object.smooth=d!=="0"&&d!=="off"}else t.object.smooth=!0;const u=t.object.currentMaterial();u&&(u.smooth=t.object.smooth)}else{if(l==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}}t.finalize();const r=new En;if(r.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let a=0,c=t.objects.length;a<c;a++){const l=t.objects[a],h=l.geometry,u=l.materials,d=h.type==="Line",p=h.type==="Points";let g=!1;if(h.vertices.length===0)continue;const x=new Xe;x.setAttribute("position",new Je(h.vertices,3)),h.normals.length>0&&x.setAttribute("normal",new Je(h.normals,3)),h.colors.length>0&&(g=!0,x.setAttribute("color",new Je(h.colors,3))),h.hasUVIndices===!0&&x.setAttribute("uv",new Je(h.uvs,2));const v=[];for(let f=0,T=u.length;f<T;f++){const y=u[f],E=y.name+"_"+y.smooth+"_"+g;let A=t.materials[E];if(this.materials!==null){if(A=this.materials.create(y.name),d&&A&&!(A instanceof fn)){const L=new fn;ct.prototype.copy.call(L,A),L.color.copy(A.color),A=L}else if(p&&A&&!(A instanceof Qn)){const L=new Qn({size:10,sizeAttenuation:!1});ct.prototype.copy.call(L,A),L.color.copy(A.color),L.map=A.map,A=L}}A===void 0&&(d?A=new fn:p?A=new Qn({size:1,sizeAttenuation:!1}):A=new kl,A.name=y.name,A.flatShading=!y.smooth,A.vertexColors=g,t.materials[E]=A),v.push(A)}let m;if(v.length>1){for(let f=0,T=u.length;f<T;f++){const y=u[f];x.addGroup(y.groupStart,y.groupCount,f)}d?m=new zi(x,v):p?m=new Cr(x,v):m=new st(x,v)}else d?m=new zi(x,v[0]):p?m=new Cr(x,v[0]):m=new st(x,v[0]);m.name=l.name,r.add(m)}else if(t.vertices.length>0){const a=new Qn({size:1,sizeAttenuation:!1}),c=new Xe;c.setAttribute("position",new Je(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(c.setAttribute("color",new Je(t.colors,3)),a.vertexColors=!0);const l=new Cr(c,a);r.add(l)}return r}}class Cg extends En{constructor(e){super(),this.animation=this.floatAnim,this.goingHome=!1,this.homeTimeout=null,this.home={position:new w(e.position.x,e.position.y,e.position.z),rotation:new gn(e.rotation.x,e.rotation.y,e.rotation.z)},this.reset()}reset(){this.position.copy(this.home.position),this.rotation.copy(this.home.rotation),this.speed=new w,this.rotSpeed=new gn,this.acceleration=new w}homeAnim(e){if(!this.goingHome){this.goingHome=!0;const t=1;this.speed.subVectors(this.home.position,this.position).multiplyScalar(1/t);const n=this.rotSpeed.toVector3();n.subVectors(this.home.rotation,this.rotation).multiplyScalar(1/t),this.rotSpeed.setFromVector3(n),this.homeTimeout=setTimeout(()=>{this.goingHome=!1,this.reset(),this.startFloat()},t*1e3)}this.position.addScaledVector(this.speed,e),this.rotation.setFromVector3(this.rotation.toVector3().addScaledVector(this.rotSpeed,e))}startFloat(){this.acceleration.y=-.01,this.animation=this.floatAnim}floatAnim(){this.position.y<-2&&(this.acceleration.y=.01),this.position.y>2&&(this.acceleration.y=-.01),this.speed.y=Math.min(this.speed.y+this.acceleration.y,.1),this.position.y+=this.speed.y}rotateAnim(){this.rotation.y+=.02}lookAtAnim(e,{x:t,y:n,z:i}){const r=new w(t,n,i).sub(this.position);this.lookAt(r)}}function Lg(s,e,t){const o=t/2.2,a=new fi;return a.moveTo(0,0+t),a.lineTo(0,0+e-t),a.quadraticCurveTo(0,0+e,0+t,0+e),a.lineTo(s/2-25/2-o,0+e),a.quadraticCurveTo(s/2-25/2,0+e,s/2-25/2,0+e-o/10),a.quadraticCurveTo(s/2-25/2,0+e-o,s/2-25/2+o,0+e-o),a.lineTo(s/2+25/2-o,0+e-o),a.quadraticCurveTo(s/2+25/2,0+e-o,s/2+25/2,0+e-o/10),a.quadraticCurveTo(s/2+25/2,0+e,s/2+25/2+o,0+e),a.lineTo(0+s-t,0+e),a.quadraticCurveTo(0+s,0+e,0+s,0+e-t),a.lineTo(0+s,0+t),a.quadraticCurveTo(0+s,0,0+s-t,0),a.lineTo(0+t,0),a.quadraticCurveTo(0,0,0,0+t),new qr(a)}const Rg=new URL("/vue-three-d-mockup/assets/iphone.4fe8eea4.obj",self.location).href,Pg={name:"Mockup",props:{screen:{type:null},lightClr:{type:String,default:"white"},phoneClr:{type:String,default:"white"},position:{type:Object,default:()=>({})},rotation:{type:Object,default:()=>({})},linearFilter:{type:Boolean}},setup(s){const e=oc(null);let t,n;const i=[];let r,o=0,a=0;function c(){const x=()=>{t=new gt(45,e.value.clientWidth/e.value.clientHeight,.1,1e4),n=new oo;const m=new Kl(s.lightClr);n.add(m),m.position.set(0,0,300),t.position.set(0,0,200)},v=(m,f)=>{const T=new Cg({position:{x:0,y:0,z:0,...f.position},rotation:{x:-.2,y:.3,z:.06,...f.rotation}}),y=()=>{const Y=Lg(54,115.80000000000001,8);let _;typeof m=="string"?_=new Yl().load(m):_=new Il(m),_.anisotropy=r.capabilities.getMaxAnisotropy();const R=new Ys({map:_});s.linearFilter&&(R.map.minFilter=ut);const P=new st(Y,R);(()=>{const F=new Lt().setFromObject(P),I=new w;F.getSize(I);const H=new w,J=P.geometry.attributes.position,ce=P.geometry.attributes.uv;for(let U=0;U<J.count;U+=1)H.fromBufferAttribute(J,U),ce.setXY(U,(H.x-F.min.x)/I.x,(H.y-F.min.y)/I.y)})(),P.translateZ(3.6),P.geometry.center(),T.add(P)},E=()=>{new Ag().load(Rg,L=>{const j=new Ue;L.traverse(te=>{if(te instanceof st){te.material=new Ys({color:s.phoneClr}),te.geometry.center();const Y=new st(te.geometry,te.material),_=8.6;Y.rotateX(Math.PI/2),Y.scale.set(-_,_,_),j.add(Y)}}),T.add(j)})};return T.startFloat(),n.add(T),y(),E(),T};if(r=new Ve({antialias:!0,alpha:!0}),r.setPixelRatio(window.devicePixelRatio),r.setSize(e.value.clientWidth,e.value.clientHeight),x(),Array.isArray(s.screen))for(let m=0;m<=s.screen.length-1;m+=1)i.push(v(s.screen[m],{position:s.position[m],rotation:s.rotation[m]}));else i.push(v(s.screen,{position:s.position,rotation:s.rotation}));e.value.appendChild(r.domElement)}let l=0;function h(x){x*=.001;const v=x-l;l=x,requestAnimationFrame(h),i.length&&i.forEach(m=>{m.animation(v,{x:o/2,y:a/2,z:t.position.z})}),r.render(n,t)}function u(){i.length&&i.forEach(x=>{x.animation=x.lookAtAnim,x.goingHome=!1,clearTimeout(x.homeTimeout)})}function d(){i.length&&i.forEach(x=>{x.animation=x.homeAnim})}function p(x){const v=e.value.getBoundingClientRect();o=x.clientX-v.left-v.width/2,a=-(x.clientY-v.top-v.height/2)}function g(x){x.preventDefault();const v=e.value.getBoundingClientRect();o=x.touches[0].clientX-v.left-v.width/2,a=-(x.touches[0].clientY-v.top-v.height/2)}return ac(()=>{c(),h(0)}),{container:e,handleMouseEnter:u,handleMouseLeave:d,handleMouseMove:p,handleTouchMove:g}}};function Dg(s,e,t,n,i,r){return lc(),cc("div",{ref:"container",onMouseenter:e[0]||(e[0]=(...o)=>n.handleMouseEnter&&n.handleMouseEnter(...o)),onMouseleave:e[1]||(e[1]=(...o)=>n.handleMouseLeave&&n.handleMouseLeave(...o)),onMousemove:e[2]||(e[2]=(...o)=>n.handleMouseMove&&n.handleMouseMove(...o)),onTouchstart:e[3]||(e[3]=(...o)=>n.handleMouseEnter&&n.handleMouseEnter(...o)),onTouchend:e[4]||(e[4]=(...o)=>n.handleMouseLeave&&n.handleMouseLeave(...o)),onTouchmove:e[5]||(e[5]=(...o)=>n.handleTouchMove&&n.handleTouchMove(...o))},null,544)}var Fg=sc(Pg,[["render",Dg]]);export{Fg as M};
|