diff --git a/3rdparty/model-viewer.3.3.0.min.js b/3rdparty/model-viewer.3.3.0.min.js new file mode 100644 index 00000000..696cd31b --- /dev/null +++ b/3rdparty/model-viewer.3.3.0.min.js @@ -0,0 +1,1077 @@ +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */ +const t=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function e(e){return(i,n)=>void 0!==n?((t,e,i)=>{e.constructor.createProperty(i,t)})(e,i,n):t(e,i) +/** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */}var i;null===(i=window.HTMLSlotElement)||void 0===i||i.prototype.assignedElements; +/** + * @license + * Copyright 2010-2023 Three.js Authors + * SPDX-License-Identifier: MIT + */ +const n="157",r=1,s=2,a=3,o=0,l=1,c=2,h=100,u=0,d=1,A=2,p=0,m=1,g=2,f=3,v=4,E=5,_=301,y=302,x=303,S=306,C=1e3,I=1001,w=1002,M=1003,b=1004,T=1005,B=1006,R=1007,L=1008,D=1009,U=1012,P=1013,N=1014,Q=1015,F=1016,O=1020,k=1023,G=1026,H=1027,z=1028,V=1030,W=33776,q=33777,X=33778,j=33779,Y=35840,K=35842,J=37492,$=37496,Z=37808,tt=37812,et=36492,it=2201,nt=2202,rt=2300,st=2301,at=2302,ot=2400,lt=2401,ct=2402,ht=2500,ut=3001,dt="",At="srgb",pt="srgb-linear",mt="display-p3",gt="display-p3-linear",ft="linear",vt="srgb",Et="rec709",_t="p3",yt=7680,xt=35044,St="300 es",Ct=1035,It=2e3,wt=2001;class Mt{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,n=i.length;e>8&255]+bt[t>>16&255]+bt[t>>24&255]+"-"+bt[255&e]+bt[e>>8&255]+"-"+bt[e>>16&15|64]+bt[e>>24&255]+"-"+bt[63&i|128]+bt[i>>8&255]+"-"+bt[i>>16&255]+bt[i>>24&255]+bt[255&n]+bt[n>>8&255]+bt[n>>16&255]+bt[n>>24&255]).toLowerCase()}function Dt(t,e,i){return Math.max(e,Math.min(i,t))}function Ut(t,e){return(t%e+e)%e}function Pt(t,e,i){return(1-i)*t+i*e}function Nt(t){return 0==(t&t-1)&&0!==t}function Qt(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Ft(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Ot(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function kt(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const Gt={DEG2RAD:Bt,RAD2DEG:Rt,generateUUID:Lt,clamp:Dt,euclideanModulo:Ut,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:Pt,damp:function(t,e,i,n){return Pt(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(Ut(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(Tt=t);let e=Tt+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*Bt},radToDeg:function(t){return t*Rt},isPowerOfTwo:Nt,ceilPowerOfTwo:Qt,floorPowerOfTwo:Ft,setQuaternionFromProperEuler:function(t,e,i,n,r){const s=Math.cos,a=Math.sin,o=s(i/2),l=a(i/2),c=s((e+n)/2),h=a((e+n)/2),u=s((e-n)/2),d=a((e-n)/2),A=s((n-e)/2),p=a((n-e)/2);switch(r){case"XYX":t.set(o*h,l*u,l*d,o*c);break;case"YZY":t.set(l*d,o*h,l*u,o*c);break;case"ZXZ":t.set(l*u,l*d,o*h,o*c);break;case"XZX":t.set(o*h,l*p,l*A,o*c);break;case"YXY":t.set(l*A,o*h,l*p,o*c);break;case"ZYZ":t.set(l*p,l*A,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:kt,denormalize:Ot};class Ht{constructor(t=0,e=0){Ht.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Dt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,s=this.y-t.y;return this.x=r*i-s*n+t.x,this.y=r*n+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class zt{constructor(t,e,i,n,r,s,a,o,l){zt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,s,a,o,l)}set(t,e,i,n,r,s,a,o,l){const c=this.elements;return c[0]=t,c[1]=n,c[2]=a,c[3]=e,c[4]=r,c[5]=o,c[6]=i,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[3],o=i[6],l=i[1],c=i[4],h=i[7],u=i[2],d=i[5],A=i[8],p=n[0],m=n[3],g=n[6],f=n[1],v=n[4],E=n[7],_=n[2],y=n[5],x=n[8];return r[0]=s*p+a*f+o*_,r[3]=s*m+a*v+o*y,r[6]=s*g+a*E+o*x,r[1]=l*p+c*f+h*_,r[4]=l*m+c*v+h*y,r[7]=l*g+c*E+h*x,r[2]=u*p+d*f+A*_,r[5]=u*m+d*v+A*y,r[8]=u*g+d*E+A*x,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8];return e*s*c-e*a*l-i*r*c+i*a*o+n*r*l-n*s*o}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,A=e*h+i*u+n*d;if(0===A)return this.set(0,0,0,0,0,0,0,0,0);const p=1/A;return t[0]=h*p,t[1]=(n*l-c*i)*p,t[2]=(a*i-n*s)*p,t[3]=u*p,t[4]=(c*e-n*o)*p,t[5]=(n*r-a*e)*p,t[6]=d*p,t[7]=(i*o-l*e)*p,t[8]=(s*e-i*r)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(i*o,i*l,-i*(o*s+l*a)+s+t,-n*l,n*o,-n*(-l*s+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Vt.makeScale(t,e)),this}rotate(t){return this.premultiply(Vt.makeRotation(-t)),this}translate(t,e){return this.premultiply(Vt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const Vt=new zt;function Wt(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function qt(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Xt(){const t=qt("canvas");return t.style.display="block",t}const jt={};function Yt(t){t in jt||(jt[t]=!0,console.warn(t))}const Kt=(new zt).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Jt=(new zt).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),$t={[pt]:{transfer:ft,primaries:Et,toReference:t=>t,fromReference:t=>t},[At]:{transfer:vt,primaries:Et,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[gt]:{transfer:ft,primaries:_t,toReference:t=>t.applyMatrix3(Jt),fromReference:t=>t.applyMatrix3(Kt)},[mt]:{transfer:vt,primaries:_t,toReference:t=>t.convertSRGBToLinear().applyMatrix3(Jt),fromReference:t=>t.applyMatrix3(Kt).convertLinearToSRGB()}},Zt=new Set([pt,gt]),te={enabled:!0,_workingColorSpace:pt,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(t){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!t},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!Zt.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,i){if(!1===this.enabled||e===i||!e||!i)return t;const n=$t[e].toReference;return(0,$t[i].fromReference)(n(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return $t[t].primaries},getTransfer:function(t){return t===dt?ft:$t[t].transfer}};function ee(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function ie(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let ne;class re{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===ne&&(ne=qt("canvas")),ne.width=t.width,ne.height=t.height;const i=ne.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=ne}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=qt("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),r=n.data;for(let t=0;t0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case C:t.x=t.x-Math.floor(t.x);break;case I:t.x=t.x<0?0:1;break;case w:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case C:t.y=t.y-Math.floor(t.y);break;case I:t.y=t.y<0?0:1;break;case w:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Yt("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===At?ut:3e3}set encoding(t){Yt("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===ut?At:dt}}ce.DEFAULT_IMAGE=null,ce.DEFAULT_MAPPING=300,ce.DEFAULT_ANISOTROPY=1;class he{constructor(t=0,e=0,i=0,n=1){he.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12]*r,this.y=s[1]*e+s[5]*i+s[9]*n+s[13]*r,this.z=s[2]*e+s[6]*i+s[10]*n+s[14]*r,this.w=s[3]*e+s[7]*i+s[11]*n+s[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,r;const s=.01,a=.1,o=t.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],A=o[9],p=o[2],m=o[6],g=o[10];if(Math.abs(c-u)o&&t>f?tf?o=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),s=Math.atan2(r,e*i);t=Math.sin(t*s)/r,a=Math.sin(a*s)/r}const r=a*i;if(o=o*t+u*r,l=l*t+d*r,c=c*t+A*r,h=h*t+p*r,t===1-a){const t=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=t,l*=t,c*=t,h*=t}}t[e]=o,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,n,r,s){const a=i[n],o=i[n+1],l=i[n+2],c=i[n+3],h=r[s],u=r[s+1],d=r[s+2],A=r[s+3];return t[e]=a*A+c*h+o*d-l*u,t[e+1]=o*A+c*u+l*h-a*d,t[e+2]=l*A+c*d+a*u-o*h,t[e+3]=c*A-a*h-o*u-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){const i=t._x,n=t._y,r=t._z,s=t._order,a=Math.cos,o=Math.sin,l=a(i/2),c=a(n/2),h=a(r/2),u=o(i/2),d=o(n/2),A=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*A,this._y=l*d*h-u*c*A,this._z=l*c*A+u*d*h,this._w=l*c*h-u*d*A;break;case"YXZ":this._x=u*c*h+l*d*A,this._y=l*d*h-u*c*A,this._z=l*c*A-u*d*h,this._w=l*c*h+u*d*A;break;case"ZXY":this._x=u*c*h-l*d*A,this._y=l*d*h+u*c*A,this._z=l*c*A+u*d*h,this._w=l*c*h-u*d*A;break;case"ZYX":this._x=u*c*h-l*d*A,this._y=l*d*h+u*c*A,this._z=l*c*A-u*d*h,this._w=l*c*h+u*d*A;break;case"YZX":this._x=u*c*h+l*d*A,this._y=l*d*h+u*c*A,this._z=l*c*A-u*d*h,this._w=l*c*h-u*d*A;break;case"XZY":this._x=u*c*h-l*d*A,this._y=l*d*h-u*c*A,this._z=l*c*A+u*d*h,this._w=l*c*h+u*d*A;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10],u=i+a+h;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(c-o)*t,this._y=(r-l)*t,this._z=(s-n)*t}else if(i>a&&i>h){const t=2*Math.sqrt(1+i-a-h);this._w=(c-o)/t,this._x=.25*t,this._y=(n+s)/t,this._z=(r+l)/t}else if(a>h){const t=2*Math.sqrt(1+a-i-h);this._w=(r-l)/t,this._x=(n+s)/t,this._y=.25*t,this._z=(o+c)/t}else{const t=2*Math.sqrt(1+h-i-a);this._w=(s-n)/t,this._x=(r+l)/t,this._y=(o+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Dt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,r=t._z,s=t._w,a=e._x,o=e._y,l=e._z,c=e._w;return this._x=i*c+s*a+n*l-r*o,this._y=n*c+s*o+r*a-i*l,this._z=r*c+s*l+i*o-n*a,this._w=s*c-i*a-n*o-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,s=this._w;let a=s*t._w+i*t._x+n*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=i,this._y=n,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-e)*c)/l,u=Math.sin(e*c)/l;return this._w=s*h+this._w*u,this._x=i*h+this._x*u,this._y=n*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=Math.random(),e=Math.sqrt(1-t),i=Math.sqrt(t),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(n),i*Math.sin(r),i*Math.cos(r),e*Math.sin(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ge{constructor(t=0,e=0,i=0){ge.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ve.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ve.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,s=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*s,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*s,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z,o=t.w,l=o*e+s*n-a*i,c=o*i+a*e-r*n,h=o*n+r*i-s*e,u=-r*e-s*i-a*n;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,r=t.z,s=e.x,a=e.y,o=e.z;return this.x=n*o-r*a,this.y=r*s-i*o,this.z=i*a-n*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return fe.copy(this).projectOnVector(t),this.sub(fe)}reflect(t){return this.sub(fe.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Dt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,i=Math.sqrt(1-t**2);return this.x=i*Math.cos(e),this.y=i*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const fe=new ge,ve=new me;class Ee{constructor(t=new ge(1/0,1/0,1/0),e=new ge(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,ye),ye.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Te),Be.subVectors(this.max,Te),Se.subVectors(t.a,Te),Ce.subVectors(t.b,Te),Ie.subVectors(t.c,Te),we.subVectors(Ce,Se),Me.subVectors(Ie,Ce),be.subVectors(Se,Ie);let e=[0,-we.z,we.y,0,-Me.z,Me.y,0,-be.z,be.y,we.z,0,-we.x,Me.z,0,-Me.x,be.z,0,-be.x,-we.y,we.x,0,-Me.y,Me.x,0,-be.y,be.x,0];return!!De(e,Se,Ce,Ie,Be)&&(e=[1,0,0,0,1,0,0,0,1],!!De(e,Se,Ce,Ie,Be)&&(Re.crossVectors(we,Me),e=[Re.x,Re.y,Re.z],De(e,Se,Ce,Ie,Be)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ye).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ye).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(_e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),_e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),_e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),_e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),_e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),_e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),_e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),_e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(_e)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const _e=[new ge,new ge,new ge,new ge,new ge,new ge,new ge,new ge],ye=new ge,xe=new Ee,Se=new ge,Ce=new ge,Ie=new ge,we=new ge,Me=new ge,be=new ge,Te=new ge,Be=new ge,Re=new ge,Le=new ge;function De(t,e,i,n,r){for(let s=0,a=t.length-3;s<=a;s+=3){Le.fromArray(t,s);const a=r.x*Math.abs(Le.x)+r.y*Math.abs(Le.y)+r.z*Math.abs(Le.z),o=e.dot(Le),l=i.dot(Le),c=n.dot(Le);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const Ue=new Ee,Pe=new ge,Ne=new ge;class Qe{constructor(t=new ge,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):Ue.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Pe.subVectors(t,this.center);const e=Pe.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.addScaledVector(Pe,i/t),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Ne.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Pe.copy(t.center).add(Ne)),this.expandByPoint(Pe.copy(t.center).sub(Ne))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Fe=new ge,Oe=new ge,ke=new ge,Ge=new ge,He=new ge,ze=new ge,Ve=new ge;class We{constructor(t=new ge,e=new ge(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Fe)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Fe.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Fe.copy(this.origin).addScaledVector(this.direction,e),Fe.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){Oe.copy(t).add(e).multiplyScalar(.5),ke.copy(e).sub(t).normalize(),Ge.copy(this.origin).sub(Oe);const r=.5*t.distanceTo(e),s=-this.direction.dot(ke),a=Ge.dot(this.direction),o=-Ge.dot(ke),l=Ge.lengthSq(),c=Math.abs(1-s*s);let h,u,d,A;if(c>0)if(h=s*o-a,u=s*a-o,A=r*c,h>=0)if(u>=-A)if(u<=A){const t=1/c;h*=t,u*=t,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-A?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=A?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,h),n&&n.copy(Oe).addScaledVector(ke,u),d}intersectSphere(t,e){Fe.subVectors(t.center,this.origin);const i=Fe.dot(this.direction),n=Fe.dot(Fe)-i*i,r=t.radius*t.radius;if(n>r)return null;const s=Math.sqrt(r-n),a=i-s,o=i+s;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(i=(t.min.x-u.x)*l,n=(t.max.x-u.x)*l):(i=(t.max.x-u.x)*l,n=(t.min.x-u.x)*l),c>=0?(r=(t.min.y-u.y)*c,s=(t.max.y-u.y)*c):(r=(t.max.y-u.y)*c,s=(t.min.y-u.y)*c),i>s||r>n?null:((r>i||isNaN(i))&&(i=r),(s=0?(a=(t.min.z-u.z)*h,o=(t.max.z-u.z)*h):(a=(t.max.z-u.z)*h,o=(t.min.z-u.z)*h),i>o||a>n?null:((a>i||i!=i)&&(i=a),(o=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Fe)}intersectTriangle(t,e,i,n,r){He.subVectors(e,t),ze.subVectors(i,t),Ve.crossVectors(He,ze);let s,a=this.direction.dot(Ve);if(a>0){if(n)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}Ge.subVectors(this.origin,t);const o=s*this.direction.dot(ze.crossVectors(Ge,ze));if(o<0)return null;const l=s*this.direction.dot(He.cross(Ge));if(l<0)return null;if(o+l>a)return null;const c=-s*Ge.dot(Ve);return c<0?null:this.at(c/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class qe{constructor(t,e,i,n,r,s,a,o,l,c,h,u,d,A,p,m){qe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,n,r,s,a,o,l,c,h,u,d,A,p,m)}set(t,e,i,n,r,s,a,o,l,c,h,u,d,A,p,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=A,g[11]=p,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new qe).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/Xe.setFromMatrixColumn(t,0).length(),r=1/Xe.setFromMatrixColumn(t,1).length(),s=1/Xe.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,r=t.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(n),l=Math.sin(n),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=s*c,i=s*h,n=a*c,r=a*h;e[0]=o*c,e[4]=-o*h,e[8]=l,e[1]=i+n*l,e[5]=t-r*l,e[9]=-a*o,e[2]=r-t*l,e[6]=n+i*l,e[10]=s*o}else if("YXZ"===t.order){const t=o*c,i=o*h,n=l*c,r=l*h;e[0]=t+r*a,e[4]=n*a-i,e[8]=s*l,e[1]=s*h,e[5]=s*c,e[9]=-a,e[2]=i*a-n,e[6]=r+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*c,i=o*h,n=l*c,r=l*h;e[0]=t-r*a,e[4]=-s*h,e[8]=n+i*a,e[1]=i+n*a,e[5]=s*c,e[9]=r-t*a,e[2]=-s*l,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*c,i=s*h,n=a*c,r=a*h;e[0]=o*c,e[4]=n*l-i,e[8]=t*l+r,e[1]=o*h,e[5]=r*l+t,e[9]=i*l-n,e[2]=-l,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*c,e[4]=r-t*h,e[8]=n*h+i,e[1]=h,e[5]=s*c,e[9]=-a*c,e[2]=-l*c,e[6]=i*h+n,e[10]=t-r*h}else if("XZY"===t.order){const t=s*o,i=s*l,n=a*o,r=a*l;e[0]=o*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=s*c,e[9]=i*h-n,e[2]=n*h-i,e[6]=a*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ye,t,Ke)}lookAt(t,e,i){const n=this.elements;return Ze.subVectors(t,e),0===Ze.lengthSq()&&(Ze.z=1),Ze.normalize(),Je.crossVectors(i,Ze),0===Je.lengthSq()&&(1===Math.abs(i.z)?Ze.x+=1e-4:Ze.z+=1e-4,Ze.normalize(),Je.crossVectors(i,Ze)),Je.normalize(),$e.crossVectors(Ze,Je),n[0]=Je.x,n[4]=$e.x,n[8]=Ze.x,n[1]=Je.y,n[5]=$e.y,n[9]=Ze.y,n[2]=Je.z,n[6]=$e.z,n[10]=Ze.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,r=this.elements,s=i[0],a=i[4],o=i[8],l=i[12],c=i[1],h=i[5],u=i[9],d=i[13],A=i[2],p=i[6],m=i[10],g=i[14],f=i[3],v=i[7],E=i[11],_=i[15],y=n[0],x=n[4],S=n[8],C=n[12],I=n[1],w=n[5],M=n[9],b=n[13],T=n[2],B=n[6],R=n[10],L=n[14],D=n[3],U=n[7],P=n[11],N=n[15];return r[0]=s*y+a*I+o*T+l*D,r[4]=s*x+a*w+o*B+l*U,r[8]=s*S+a*M+o*R+l*P,r[12]=s*C+a*b+o*L+l*N,r[1]=c*y+h*I+u*T+d*D,r[5]=c*x+h*w+u*B+d*U,r[9]=c*S+h*M+u*R+d*P,r[13]=c*C+h*b+u*L+d*N,r[2]=A*y+p*I+m*T+g*D,r[6]=A*x+p*w+m*B+g*U,r[10]=A*S+p*M+m*R+g*P,r[14]=A*C+p*b+m*L+g*N,r[3]=f*y+v*I+E*T+_*D,r[7]=f*x+v*w+E*B+_*U,r[11]=f*S+v*M+E*R+_*P,r[15]=f*C+v*b+E*L+_*N,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],s=t[1],a=t[5],o=t[9],l=t[13],c=t[2],h=t[6],u=t[10],d=t[14];return t[3]*(+r*o*h-n*l*h-r*a*u+i*l*u+n*a*d-i*o*d)+t[7]*(+e*o*d-e*l*u+r*s*u-n*s*d+n*l*c-r*o*c)+t[11]*(+e*l*h-e*a*d-r*s*h+i*s*d+r*a*c-i*l*c)+t[15]*(-n*a*c-e*o*h+e*a*u+n*s*h-i*s*u+i*o*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],s=t[4],a=t[5],o=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11],A=t[12],p=t[13],m=t[14],g=t[15],f=h*m*l-p*u*l+p*o*d-a*m*d-h*o*g+a*u*g,v=A*u*l-c*m*l-A*o*d+s*m*d+c*o*g-s*u*g,E=c*p*l-A*h*l+A*a*d-s*p*d-c*a*g+s*h*g,_=A*h*o-c*p*o-A*a*u+s*p*u+c*a*m-s*h*m,y=e*f+i*v+n*E+r*_;if(0===y)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const x=1/y;return t[0]=f*x,t[1]=(p*u*r-h*m*r-p*n*d+i*m*d+h*n*g-i*u*g)*x,t[2]=(a*m*r-p*o*r+p*n*l-i*m*l-a*n*g+i*o*g)*x,t[3]=(h*o*r-a*u*r-h*n*l+i*u*l+a*n*d-i*o*d)*x,t[4]=v*x,t[5]=(c*m*r-A*u*r+A*n*d-e*m*d-c*n*g+e*u*g)*x,t[6]=(A*o*r-s*m*r-A*n*l+e*m*l+s*n*g-e*o*g)*x,t[7]=(s*u*r-c*o*r+c*n*l-e*u*l-s*n*d+e*o*d)*x,t[8]=E*x,t[9]=(A*h*r-c*p*r-A*i*d+e*p*d+c*i*g-e*h*g)*x,t[10]=(s*p*r-A*a*r+A*i*l-e*p*l-s*i*g+e*a*g)*x,t[11]=(c*a*r-s*h*r-c*i*l+e*h*l+s*i*d-e*a*d)*x,t[12]=_*x,t[13]=(c*p*n-A*h*n+A*i*u-e*p*u-c*i*m+e*h*m)*x,t[14]=(A*a*n-s*p*n-A*i*o+e*p*o+s*i*m-e*a*m)*x,t[15]=(s*h*n-c*a*n+c*i*o-e*h*o-s*i*u+e*a*u)*x,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,s=t.x,a=t.y,o=t.z,l=r*s,c=r*a;return this.set(l*s+i,l*a-n*o,l*o+n*a,0,l*a+n*o,c*a+i,c*o-n*s,0,l*o-n*a,c*o+n*s,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,r,s){return this.set(1,i,r,0,t,1,s,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,s=e._y,a=e._z,o=e._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,A=r*h,p=s*c,m=s*h,g=a*h,f=o*l,v=o*c,E=o*h,_=i.x,y=i.y,x=i.z;return n[0]=(1-(p+g))*_,n[1]=(d+E)*_,n[2]=(A-v)*_,n[3]=0,n[4]=(d-E)*y,n[5]=(1-(u+g))*y,n[6]=(m+f)*y,n[7]=0,n[8]=(A+v)*x,n[9]=(m-f)*x,n[10]=(1-(u+p))*x,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=Xe.set(n[0],n[1],n[2]).length();const s=Xe.set(n[4],n[5],n[6]).length(),a=Xe.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],je.copy(this);const o=1/r,l=1/s,c=1/a;return je.elements[0]*=o,je.elements[1]*=o,je.elements[2]*=o,je.elements[4]*=l,je.elements[5]*=l,je.elements[6]*=l,je.elements[8]*=c,je.elements[9]*=c,je.elements[10]*=c,e.setFromRotationMatrix(je),i.x=r,i.y=s,i.z=a,this}makePerspective(t,e,i,n,r,s,a=2e3){const o=this.elements,l=2*r/(e-t),c=2*r/(i-n),h=(e+t)/(e-t),u=(i+n)/(i-n);let d,A;if(a===It)d=-(s+r)/(s-r),A=-2*s*r/(s-r);else{if(a!==wt)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),A=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=A,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,n,r,s,a=2e3){const o=this.elements,l=1/(e-t),c=1/(i-n),h=1/(s-r),u=(e+t)*l,d=(i+n)*c;let A,p;if(a===It)A=(s+r)*h,p=-2*h;else{if(a!==wt)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);A=r*h,p=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=p,o[14]=-A,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Xe=new ge,je=new qe,Ye=new ge(0,0,0),Ke=new ge(1,1,1),Je=new ge,$e=new ge,Ze=new ge,ti=new qe,ei=new me;class ii{constructor(t=0,e=0,i=0,n=ii.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,r=n[0],s=n[4],a=n[8],o=n[1],l=n[5],c=n[9],h=n[2],u=n[6],d=n[10];switch(e){case"XYZ":this._y=Math.asin(Dt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Dt(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Dt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-Dt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(Dt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-Dt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return ti.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ti,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ei.setFromEuler(this),this.setFromQuaternion(ei,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ii.DEFAULT_ORDER="XYZ";class ni{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(i=i.concat(r))}return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ci,t,hi),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ci,ui,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const i=e.shapes;if(Array.isArray(i))for(let e=0,n=i.length;e0){n.children=[];for(let e=0;e0){n.animations=[];for(let e=0;e0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),c.length>0&&(i.animations=c),h.length>0&&(i.nodes=h)}return i.object=n,i;function s(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){vi.subVectors(n,e),Ei.subVectors(i,e),_i.subVectors(t,e);const s=vi.dot(vi),a=vi.dot(Ei),o=vi.dot(_i),l=Ei.dot(Ei),c=Ei.dot(_i),h=s*l-a*a;if(0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,A=(s*c-a*o)*u;return r.set(1-d-A,A,d)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,yi),yi.x>=0&&yi.y>=0&&yi.x+yi.y<=1}static getUV(t,e,i,n,r,s,a,o){return!1===bi&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),bi=!0),this.getInterpolation(t,e,i,n,r,s,a,o)}static getInterpolation(t,e,i,n,r,s,a,o){return this.getBarycoord(t,e,i,n,yi),o.setScalar(0),o.addScaledVector(r,yi.x),o.addScaledVector(s,yi.y),o.addScaledVector(a,yi.z),o}static isFrontFacing(t,e,i,n){return vi.subVectors(i,e),Ei.subVectors(t,e),vi.cross(Ei).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return vi.subVectors(this.c,this.b),Ei.subVectors(this.a,this.b),.5*vi.cross(Ei).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ti.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ti.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,r){return!1===bi&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),bi=!0),Ti.getInterpolation(t,this.a,this.b,this.c,e,i,n,r)}getInterpolation(t,e,i,n,r){return Ti.getInterpolation(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return Ti.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ti.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,r=this.c;let s,a;xi.subVectors(n,i),Si.subVectors(r,i),Ii.subVectors(t,i);const o=xi.dot(Ii),l=Si.dot(Ii);if(o<=0&&l<=0)return e.copy(i);wi.subVectors(t,n);const c=xi.dot(wi),h=Si.dot(wi);if(c>=0&&h<=c)return e.copy(n);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),e.copy(i).addScaledVector(xi,s);Mi.subVectors(t,r);const d=xi.dot(Mi),A=Si.dot(Mi);if(A>=0&&d<=A)return e.copy(r);const p=d*l-o*A;if(p<=0&&l>=0&&A<=0)return a=l/(l-A),e.copy(i).addScaledVector(Si,a);const m=c*A-d*h;if(m<=0&&h-c>=0&&d-A>=0)return Ci.subVectors(r,n),a=(h-c)/(h-c+(d-A)),e.copy(n).addScaledVector(Ci,a);const g=1/(m+p+u);return s=p*g,a=u*g,e.copy(i).addScaledVector(xi,s).addScaledVector(Si,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Bi=0;class Ri extends Mt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Bi++}),this.uuid=Lt(),this.name="",this.type="Material",this.blending=1,this.side=o,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=h,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=yt,this.stencilZFail=yt,this.stencilZPass=yt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const i=t[e];if(void 0===i){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),this.side!==o&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}const Li={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},Di={h:0,s:0,l:0},Ui={h:0,s:0,l:0};function Pi(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}class Ni{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(void 0===e&&void 0===i){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=At){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,te.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=te.workingColorSpace){return this.r=t,this.g=e,this.b=i,te.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=te.workingColorSpace){if(t=Ut(t,1),e=Dt(e,0,1),i=Dt(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=Pi(r,n,t+1/3),this.g=Pi(r,n,t),this.b=Pi(r,n,t-1/3)}return te.toWorkingColorSpace(this,n),this}setStyle(t,e=At){function i(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const s=n[1],a=n[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(i,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=At){const i=Li[t.toLowerCase()];return void 0!==i?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ee(t.r),this.g=ee(t.g),this.b=ee(t.b),this}copyLinearToSRGB(t){return this.r=ie(t.r),this.g=ie(t.g),this.b=ie(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=At){return te.fromWorkingColorSpace(Qi.copy(this),t),65536*Math.round(Dt(255*Qi.r,0,255))+256*Math.round(Dt(255*Qi.g,0,255))+Math.round(Dt(255*Qi.b,0,255))}getHexString(t=At){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=te.workingColorSpace){te.fromWorkingColorSpace(Qi.copy(this),e);const i=Qi.r,n=Qi.g,r=Qi.b,s=Math.max(i,n,r),a=Math.min(i,n,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const t=s-a;switch(l=c<=.5?t/(s+a):t/(2-s-a),s){case i:o=(n-r)/t+(n>-e-14,n[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(n[t]=e+15<<10,n[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(n[t]=31744,n[256|t]=64512,r[t]=24,r[256|t]=24):(n[t]=31744,n[256|t]=64512,r[t]=13,r[256|t]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;0==(8388608&e);)e<<=1,i-=8388608;e&=-8388609,i+=947912704,s[t]=e|i}for(let t=1024;t<2048;++t)s[t]=939524096+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=1199570944,a[32]=2147483648;for(let t=33;t<63;++t)a[t]=2147483648+(t-32<<23);a[63]=3347054592;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:i,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}const Gi={toHalfFloat:function(t){Math.abs(t)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),t=Dt(t,-65504,65504),Oi.floatView[0]=t;const e=Oi.uint32View[0],i=e>>23&511;return Oi.baseTable[i]+((8388607&e)>>Oi.shiftTable[i])},fromHalfFloat:function(t){const e=t>>10;return Oi.uint32View[0]=Oi.mantissaTable[Oi.offsetTable[e]+(1023&t)]+Oi.exponentTable[e],Oi.floatView[0]}},Hi=new ge,zi=new Ht;class Vi{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=xt,this.updateRange={offset:0,count:-1},this.gpuType=Q,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,r=this.itemSize;n0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],s=[];for(let e=0,n=i.length;e0&&(n[e]=s,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(t.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t(t.far-t.near)**2)return}nn.copy(r).invert(),rn.copy(t.ray).applyMatrix4(nn),null!==i.boundingBox&&!1===rn.intersectsBox(i.boundingBox)||this._computeIntersections(t,e,rn)}}_computeIntersections(t,e,i){let n;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;ri.far?null:{distance:u,point:En.clone(),object:t}}(t,e,i,n,on,ln,cn,vn);if(d){r&&(dn.fromBufferAttribute(r,c),An.fromBufferAttribute(r,h),pn.fromBufferAttribute(r,u),d.uv=Ti.getInterpolation(vn,on,ln,cn,dn,An,pn,new Ht)),s&&(dn.fromBufferAttribute(s,c),An.fromBufferAttribute(s,h),pn.fromBufferAttribute(s,u),d.uv1=Ti.getInterpolation(vn,on,ln,cn,dn,An,pn,new Ht),d.uv2=d.uv1),a&&(mn.fromBufferAttribute(a,c),gn.fromBufferAttribute(a,h),fn.fromBufferAttribute(a,u),d.normal=Ti.getInterpolation(vn,on,ln,cn,mn,gn,fn,new ge),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const t={a:c,b:h,c:u,normal:new ge,materialIndex:0};Ti.getNormal(on,ln,cn,t.normal),d.face=t}return d}class xn extends en{constructor(t=1,e=1,i=1,n=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:s};const a=this;n=Math.floor(n),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function A(t,e,i,n,r,s,A,p,m,g,f){const v=s/m,E=A/g,_=s/2,y=A/2,x=p/2,S=m+1,C=g+1;let I=0,w=0;const M=new ge;for(let s=0;s0?1:-1,c.push(M.x,M.y,M.z),h.push(o/m),h.push(1-s/g),I+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class bn extends fi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe,this.coordinateSystem=It}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class Tn extends bn{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*Rt*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*Bt*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*Rt*Math.atan(Math.tan(.5*Bt*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,i,n,r,s){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*Bt*this.fov)/this.zoom,i=2*e,n=this.aspect*i,r=-.5*n;const s=this.view;if(null!==this.view&&this.view.enabled){const t=s.fullWidth,a=s.fullHeight;r+=s.offsetX*n/t,e-=s.offsetY*i/a,n*=s.width/t,i*=s.height/a}const a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Bn=-90;class Rn extends fi{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Tn(Bn,1,t,e);n.layers=this.layers,this.add(n);const r=new Tn(Bn,1,t,e);r.layers=this.layers,this.add(r);const s=new Tn(Bn,1,t,e);s.layers=this.layers,this.add(s);const a=new Tn(Bn,1,t,e);a.layers=this.layers,this.add(a);const o=new Tn(Bn,1,t,e);o.layers=this.layers,this.add(o);const l=new Tn(Bn,1,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,r,s,a,o]=e;for(const t of e)this.remove(t);if(t===It)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(t!==wt)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,s,a,o,l,c]=this.children,h=t.getRenderTarget(),u=t.getActiveCubeFace(),d=t.getActiveMipmapLevel(),A=t.xr.enabled;t.xr.enabled=!1;const p=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,n),t.render(e,r),t.setRenderTarget(i,1,n),t.render(e,s),t.setRenderTarget(i,2,n),t.render(e,a),t.setRenderTarget(i,3,n),t.render(e,o),t.setRenderTarget(i,4,n),t.render(e,l),i.texture.generateMipmaps=p,t.setRenderTarget(i,5,n),t.render(e,c),t.setRenderTarget(h,u,d),t.xr.enabled=A,i.texture.needsPMREMUpdate=!0}}class Ln extends ce{constructor(t,e,i,n,r,s,a,o,l,c){super(t=void 0!==t?t:[],e=void 0!==e?e:_,i,n,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Dn extends de{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1},n=[i,i,i,i,i,i];void 0!==e.encoding&&(Yt("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===ut?At:dt),this.texture=new Ln(n,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:B}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},n=new xn(5,5,5),r=new Mn({name:"CubemapFromEquirect",uniforms:Sn(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:l,blending:0});r.uniforms.tEquirect.value=e;const s=new _n(n,r),a=e.minFilter;e.minFilter===L&&(e.minFilter=B);return new Rn(1,10,this).update(t,s),e.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(t,e,i,n){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}const Un=new ge,Pn=new ge,Nn=new zt;class Qn{constructor(t=new ge(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=Un.subVectors(i,e).cross(Pn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const i=t.delta(Un),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||Nn.getNormalMatrix(t),n=this.coplanarPoint(Un).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Fn=new Qe,On=new ge;class kn{constructor(t=new Qn,e=new Qn,i=new Qn,n=new Qn,r=new Qn,s=new Qn){this.planes=[t,e,i,n,r,s]}set(t,e,i,n,r,s){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(r),a[5].copy(s),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3){const i=this.planes,n=t.elements,r=n[0],s=n[1],a=n[2],o=n[3],l=n[4],c=n[5],h=n[6],u=n[7],d=n[8],A=n[9],p=n[10],m=n[11],g=n[12],f=n[13],v=n[14],E=n[15];if(i[0].setComponents(o-r,u-l,m-d,E-g).normalize(),i[1].setComponents(o+r,u+l,m+d,E+g).normalize(),i[2].setComponents(o+s,u+c,m+A,E+f).normalize(),i[3].setComponents(o-s,u-c,m-A,E-f).normalize(),i[4].setComponents(o-a,u-h,m-p,E-v).normalize(),e===It)i[5].setComponents(o+a,u+h,m+p,E+v).normalize();else{if(e!==wt)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);i[5].setComponents(a,h,p,v).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),Fn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),Fn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Fn)}intersectsSprite(t){return Fn.center.set(0,0,0),Fn.radius=.7071067811865476,Fn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Fn)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,On.y=n.normal.y>0?t.max.y:t.min.y,On.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(On)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Gn(){let t=null,e=!1,i=null,n=null;function r(e,s){i(e,s),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function Hn(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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 );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal;\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = 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 );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},Wn={common:{diffuse:{value:new Ni(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new zt}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new zt},normalScale:{value:new Ht(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new zt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ni(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 Ni(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0},uvTransform:{value:new zt}},sprite:{diffuse:{value:new Ni(16777215)},opacity:{value:1},center:{value:new Ht(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}}},qn={basic:{uniforms:Cn([Wn.common,Wn.specularmap,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.fog]),vertexShader:Vn.meshbasic_vert,fragmentShader:Vn.meshbasic_frag},lambert:{uniforms:Cn([Wn.common,Wn.specularmap,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.emissivemap,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,Wn.fog,Wn.lights,{emissive:{value:new Ni(0)}}]),vertexShader:Vn.meshlambert_vert,fragmentShader:Vn.meshlambert_frag},phong:{uniforms:Cn([Wn.common,Wn.specularmap,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.emissivemap,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,Wn.fog,Wn.lights,{emissive:{value:new Ni(0)},specular:{value:new Ni(1118481)},shininess:{value:30}}]),vertexShader:Vn.meshphong_vert,fragmentShader:Vn.meshphong_frag},standard:{uniforms:Cn([Wn.common,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.emissivemap,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,Wn.roughnessmap,Wn.metalnessmap,Wn.fog,Wn.lights,{emissive:{value:new Ni(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vn.meshphysical_vert,fragmentShader:Vn.meshphysical_frag},toon:{uniforms:Cn([Wn.common,Wn.aomap,Wn.lightmap,Wn.emissivemap,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,Wn.gradientmap,Wn.fog,Wn.lights,{emissive:{value:new Ni(0)}}]),vertexShader:Vn.meshtoon_vert,fragmentShader:Vn.meshtoon_frag},matcap:{uniforms:Cn([Wn.common,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,Wn.fog,{matcap:{value:null}}]),vertexShader:Vn.meshmatcap_vert,fragmentShader:Vn.meshmatcap_frag},points:{uniforms:Cn([Wn.points,Wn.fog]),vertexShader:Vn.points_vert,fragmentShader:Vn.points_frag},dashed:{uniforms:Cn([Wn.common,Wn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vn.linedashed_vert,fragmentShader:Vn.linedashed_frag},depth:{uniforms:Cn([Wn.common,Wn.displacementmap]),vertexShader:Vn.depth_vert,fragmentShader:Vn.depth_frag},normal:{uniforms:Cn([Wn.common,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,{opacity:{value:1}}]),vertexShader:Vn.meshnormal_vert,fragmentShader:Vn.meshnormal_frag},sprite:{uniforms:Cn([Wn.sprite,Wn.fog]),vertexShader:Vn.sprite_vert,fragmentShader:Vn.sprite_frag},background:{uniforms:{uvTransform:{value:new zt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vn.background_vert,fragmentShader:Vn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Vn.backgroundCube_vert,fragmentShader:Vn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vn.cube_vert,fragmentShader:Vn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vn.equirect_vert,fragmentShader:Vn.equirect_frag},distanceRGBA:{uniforms:Cn([Wn.common,Wn.displacementmap,{referencePosition:{value:new ge},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vn.distanceRGBA_vert,fragmentShader:Vn.distanceRGBA_frag},shadow:{uniforms:Cn([Wn.lights,Wn.fog,{color:{value:new Ni(0)},opacity:{value:1}}]),vertexShader:Vn.shadow_vert,fragmentShader:Vn.shadow_frag}};qn.physical={uniforms:Cn([qn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new zt},clearcoatNormalScale:{value:new Ht(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new zt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new zt},sheen:{value:0},sheenColor:{value:new Ni(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new zt},transmissionSamplerSize:{value:new Ht},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new zt},attenuationDistance:{value:0},attenuationColor:{value:new Ni(0)},specularColor:{value:new Ni(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new zt},anisotropyVector:{value:new Ht},anisotropyMap:{value:null},anisotropyMapTransform:{value:new zt}}]),vertexShader:Vn.meshphysical_vert,fragmentShader:Vn.meshphysical_frag};const Xn={r:0,b:0,g:0};function jn(t,e,i,n,r,s,a){const c=new Ni(0);let h,u,d=!0===s?0:1,A=null,p=0,m=null;function g(e,i){e.getRGB(Xn,In(t)),n.buffers.color.setClear(Xn.r,Xn.g,Xn.b,i,a)}return{getClearColor:function(){return c},setClearColor:function(t,e=1){c.set(t),d=e,g(c,d)},getClearAlpha:function(){return d},setClearAlpha:function(t){d=t,g(c,d)},render:function(s,f){let v=!1,E=!0===f.isScene?f.background:null;if(E&&E.isTexture){E=(f.backgroundBlurriness>0?i:e).get(E)}null===E?g(c,d):E&&E.isColor&&(g(E,1),v=!0);const _=t.xr.getEnvironmentBlendMode();"additive"===_?n.buffers.color.setClear(0,0,0,1,a):"alpha-blend"===_&&n.buffers.color.setClear(0,0,0,0,a),(t.autoClear||v)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),E&&(E.isCubeTexture||E.mapping===S)?(void 0===u&&(u=new _n(new xn(1,1,1),new Mn({name:"BackgroundCubeMaterial",uniforms:Sn(qn.backgroundCube.uniforms),vertexShader:qn.backgroundCube.vertexShader,fragmentShader:qn.backgroundCube.fragmentShader,side:l,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),u.material.uniforms.envMap.value=E,u.material.uniforms.flipEnvMap.value=E.isCubeTexture&&!1===E.isRenderTargetTexture?-1:1,u.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,u.material.toneMapped=te.getTransfer(E.colorSpace)!==vt,A===E&&p===E.version&&m===t.toneMapping||(u.material.needsUpdate=!0,A=E,p=E.version,m=t.toneMapping),u.layers.enableAll(),s.unshift(u,u.geometry,u.material,0,0,null)):E&&E.isTexture&&(void 0===h&&(h=new _n(new zn(2,2),new Mn({name:"BackgroundMaterial",uniforms:Sn(qn.background.uniforms),vertexShader:qn.background.vertexShader,fragmentShader:qn.background.fragmentShader,side:o,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(h)),h.material.uniforms.t2D.value=E,h.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,h.material.toneMapped=te.getTransfer(E.colorSpace)!==vt,!0===E.matrixAutoUpdate&&E.updateMatrix(),h.material.uniforms.uvTransform.value.copy(E.matrix),A===E&&p===E.version&&m===t.toneMapping||(h.material.needsUpdate=!0,A=E,p=E.version,m=t.toneMapping),h.layers.enableAll(),s.unshift(h,h.geometry,h.material,0,0,null))}}}function Yn(t,e,i,n){const r=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),a=n.isWebGL2||null!==s,o={},l=A(null);let c=l,h=!1;function u(e){return n.isWebGL2?t.bindVertexArray(e):s.bindVertexArrayOES(e)}function d(e){return n.isWebGL2?t.deleteVertexArray(e):s.deleteVertexArrayOES(e)}function A(t){const e=[],i=[],n=[];for(let t=0;t=0){const i=r[e];let n=s[e];if(void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;a++}}return c.attributesNum!==a||c.index!==n}(r,E,d,_),y&&function(t,e,i,n){const r={},s=e.attributes;let a=0;const o=i.getAttributes();for(const e in o){if(o[e].location>=0){let i=s[e];void 0===i&&("instanceMatrix"===e&&t.instanceMatrix&&(i=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(i=t.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[e]=n,a++}}c.attributes=r,c.attributesNum=a,c.index=n}(r,E,d,_)}else{const t=!0===l.wireframe;c.geometry===E.id&&c.program===d.id&&c.wireframe===t||(c.geometry=E.id,c.program=d.id,c.wireframe=t,y=!0)}null!==_&&i.update(_,t.ELEMENT_ARRAY_BUFFER),(y||h)&&(h=!1,function(r,s,a,o){if(!1===n.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;p();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const e in c){const s=c[e];if(s.location>=0){let a=l[e];if(void 0===a&&("instanceMatrix"===e&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===e&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const e=a.normalized,l=a.itemSize,c=i.get(a);if(void 0===c)continue;const h=c.buffer,u=c.type,d=c.bytesPerElement,A=!0===n.isWebGL2&&(u===t.INT||u===t.UNSIGNED_INT||a.gpuType===P);if(a.isInterleavedBufferAttribute){const i=a.data,n=i.stride,c=a.offset;if(i.isInstancedInterleavedBuffer){for(let t=0;t0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===t.constructor.name;let a=void 0!==i.precision?i.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||e.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=t.getParameter(t.MAX_TEXTURE_SIZE),A=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),m=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),g=t.getParameter(t.MAX_VARYING_VECTORS),f=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=u>0,E=s||e.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:A,maxAttributes:p,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:f,vertexTextures:v,floatFragmentTextures:E,floatVertexTextures:v&&E,maxSamples:s?t.getParameter(t.MAX_SAMPLES):0}}function $n(t){const e=this;let i=null,n=0,r=!1,s=!1;const a=new Qn,o=new zt,l={value:null,needsUpdate:!1};function c(t,i,n,r){const s=null!==t?t.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const e=n+4*s,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0);e.numPlanes=n,e.numIntersection=0}();else{const t=s?0:n,e=4*t;let r=p.clippingState||null;l.value=r,r=c(u,o,e,h);for(let t=0;t!==e;++t)r[t]=i[t];p.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=t}}}function Zn(t){let e=new WeakMap;function i(t,e){return e===x?t.mapping=_:304===e&&(t.mapping=y),t}function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(s===x||304===s){if(e.has(r)){return i(e.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new Dn(s.height/2);return a.fromEquirectangularTexture(t,r),e.set(r,a),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}class tr extends bn{constructor(t=-1,e=1,i=1,n=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,s=i+t,a=n+e,o=n-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,s=r+t*this.view.width,a-=e*this.view.offsetY,o=a-e*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const er=[.125,.215,.35,.446,.526,.582],ir=20,nr=new tr,rr=new Ni;let sr=null;const ar=(1+Math.sqrt(5))/2,or=1/ar,lr=[new ge(1,1,1),new ge(-1,1,1),new ge(1,1,-1),new ge(-1,1,-1),new ge(0,ar,or),new ge(0,ar,-or),new ge(or,0,ar),new ge(-or,0,ar),new ge(ar,or,0),new ge(-ar,or,0)];class cr{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100){sr=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,i,n,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ar(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=dr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;tt-4?o=er[a-t+4-1]:0===a&&(o=0),n.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,A=6,p=3,m=2,g=1,f=new Float32Array(p*A*d),v=new Float32Array(m*A*d),E=new Float32Array(g*A*d);for(let t=0;t2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];f.set(n,p*A*t),v.set(u,m*A*t);const r=[t,t,t,t,t,t];E.set(r,g*A*t)}const _=new en;_.setAttribute("position",new Vi(f,p)),_.setAttribute("uv",new Vi(v,m)),_.setAttribute("faceIndex",new Vi(E,g)),e.push(_),r>4&&r--}return{lodPlanes:e,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function(t,e,i){const n=new Float32Array(ir),r=new ge(0,1,0),s=new Mn({name:"SphericalGaussianBlur",defines:{n:ir,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:pr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(n,t,e)}return n}_compileMaterial(t){const e=new _n(this._lodPlanes[0],t);this._renderer.compile(e,nr)}_sceneToCubeUV(t,e,i,n){const r=new Tn(90,1,e,i),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,c=o.autoClear,h=o.toneMapping;o.getClearColor(rr),o.toneMapping=p,o.autoClear=!1;const u=new Fi({name:"PMREM.Background",side:l,depthWrite:!1,depthTest:!1}),d=new _n(new xn,u);let A=!1;const m=t.background;m?m.isColor&&(u.color.copy(m),t.background=null,A=!0):(u.color.copy(rr),A=!0);for(let e=0;e<6;e++){const i=e%3;0===i?(r.up.set(0,s[e],0),r.lookAt(a[e],0,0)):1===i?(r.up.set(0,0,s[e]),r.lookAt(0,a[e],0)):(r.up.set(0,s[e],0),r.lookAt(0,0,a[e]));const l=this._cubeSize;ur(n,i*l,e>2?l:0,l,l),o.setRenderTarget(n),A&&o.render(d,r),o.render(t,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=h,o.autoClear=c,t.background=m}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===_||t.mapping===y;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ar()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=dr());const r=n?this._cubemapMaterial:this._equirectMaterial,s=new _n(this._lodPlanes[0],r);r.uniforms.envMap.value=t;const a=this._cubeSize;ur(e,0,0,3*a,2*a),i.setRenderTarget(e),i.render(s,nr)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let e=1;eir&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;tf-4?n-f+4:0),4*(this._cubeSize-v),3*v,2*v),o.setRenderTarget(e),o.render(c,nr)}}function hr(t,e,i){const n=new de(t,e,i);return n.texture.mapping=S,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ur(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function dr(){return new Mn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:pr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Ar(){return new Mn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:pr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function pr(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function mr(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===x||304===s,o=s===_||s===y;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let n=e.get(r);return null===i&&(i=new cr(t)),n=a?i.fromEquirectangular(r,n):i.fromCubemap(r,n),e.set(r,n),n.texture}if(e.has(r))return e.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(t){let e=0;const i=6;for(let n=0;ne.maxTextureSize&&(p=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const m=new Float32Array(A*p*4*r),g=new Ae(m,A,p,r);g.type=Q,g.needsUpdate=!0;const f=4*d;for(let e=0;e0)return t;const r=e*i;let s=br[r];if(void 0===s&&(s=new Float32Array(r),br[r]=s),0!==e){n.toArray(s,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(s,r)}return s}function Ur(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i":" "} ${r}: ${i[t]}`)}return n.join("\n")}(t.getShaderSource(e),n)}return r}function Rs(t,e){const i=function(t){const e=te.getPrimaries(te.workingColorSpace),i=te.getPrimaries(t);let n;switch(e===i?n="":e===_t&&i===Et?n="LinearDisplayP3ToLinearSRGB":e===Et&&i===_t&&(n="LinearSRGBToLinearDisplayP3"),t){case pt:case gt:return[n,"LinearTransferOETF"];case At:case mt:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[n,"LinearTransferOETF"]}}(e);return`vec4 ${t}( vec4 value ) { return ${i[0]}( ${i[1]}( value ) ); }`}function Ls(t,e){let i;switch(e){case m:i="Linear";break;case g:i="Reinhard";break;case f:i="OptimizedCineon";break;case v:i="ACESFilmic";break;case E:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),i="Linear"}return"vec3 "+t+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function Ds(t){return""!==t}function Us(t,e){const i=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ps(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Ns=/^[ \t]*#include +<([\w\d./]+)>/gm;function Qs(t){return t.replace(Ns,Os)}const Fs=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Os(t,e){let i=Vn[e];if(void 0===i){const t=Fs.get(e);if(void 0===t)throw new Error("Can not resolve #include <"+e+">");i=Vn[t],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,t)}return Qs(i)}const ks=/#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 Gs(t){return t.replace(ks,Hs)}function Hs(t,e,i,n){let r="";for(let t=parseInt(e);t0&&(w+="\n"),M=[x,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,C].filter(Ds).join("\n"),M.length>0&&(M+="\n")):(w=[zs(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,C,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+f:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.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","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ds).join("\n"),M=[x,zs(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,C,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+g:"",i.envMap?"#define "+f:"",i.envMap?"#define "+v:"",E?"#define CUBEUV_TEXEL_WIDTH "+E.texelWidth:"",E?"#define CUBEUV_TEXEL_HEIGHT "+E.texelHeight:"",E?"#define CUBEUV_MAX_MIP "+E.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+m:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.numLightProbes>0?"#define USE_LIGHT_PROBES":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==p?"#define TONE_MAPPING":"",i.toneMapping!==p?Vn.tonemapping_pars_fragment:"",i.toneMapping!==p?Ls("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Vn.colorspace_pars_fragment,Rs("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Ds).join("\n")),c=Qs(c),c=Us(c,i),c=Ps(c,i),h=Qs(h),h=Us(h,i),h=Ps(h,i),c=Gs(c),h=Gs(h),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(b="#version 300 es\n",w=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+w,M=["#define varying in",i.glslVersion===St?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===St?"":"#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("\n")+"\n"+M);const T=b+w+c,B=b+M+h,R=bs(o,o.VERTEX_SHADER,T),L=bs(o,o.FRAGMENT_SHADER,B);if(o.attachShader(I,R),o.attachShader(I,L),void 0!==i.index0AttributeName?o.bindAttribLocation(I,0,i.index0AttributeName):!0===i.morphTargets&&o.bindAttribLocation(I,0,"position"),o.linkProgram(I),t.debug.checkShaderErrors){const e=o.getProgramInfoLog(I).trim(),i=o.getShaderInfoLog(R).trim(),n=o.getShaderInfoLog(L).trim();let r=!0,s=!0;if(!1===o.getProgramParameter(I,o.LINK_STATUS))if(r=!1,"function"==typeof t.debug.onShaderError)t.debug.onShaderError(o,I,R,L);else{const t=Bs(o,R,"vertex"),i=Bs(o,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(I,o.VALIDATE_STATUS)+"\n\nProgram Info Log: "+e+"\n"+t+"\n"+i)}else""!==e?console.warn("THREE.WebGLProgram: Program Info Log:",e):""!==i&&""!==n||(s=!1);s&&(this.diagnostics={runnable:r,programLog:e,vertexShader:{log:i,prefix:w},fragmentShader:{log:n,prefix:M}})}let D,U;return o.deleteShader(R),o.deleteShader(L),this.getUniforms=function(){return void 0===D&&(D=new Ms(o,I)),D},this.getAttributes=function(){return void 0===U&&(U=function(t,e){const i={},n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r0,Y=s.clearcoat>0,K=s.iridescence>0,J=s.sheen>0,$=s.transmission>0,Z=j&&!!s.anisotropyMap,tt=Y&&!!s.clearcoatMap,et=Y&&!!s.clearcoatNormalMap,it=Y&&!!s.clearcoatRoughnessMap,nt=K&&!!s.iridescenceMap,rt=K&&!!s.iridescenceThicknessMap,st=J&&!!s.sheenColorMap,at=J&&!!s.sheenRoughnessMap,ot=!!s.specularMap,lt=!!s.specularColorMap,ct=!!s.specularIntensityMap,ht=$&&!!s.transmissionMap,ut=$&&!!s.thicknessMap,dt=!!s.gradientMap,At=!!s.alphaMap,mt=s.alphaTest>0,gt=!!s.alphaHash,ft=!!s.extensions,Et=!!x.attributes.uv1,_t=!!x.attributes.uv2,yt=!!x.attributes.uv3;let xt=p;return s.toneMapped&&(null!==P&&!0!==P.isXRRenderTarget||(xt=t.toneMapping)),{isWebGL2:d,shaderID:M,shaderType:s.type,shaderName:s.name,vertexShader:B,fragmentShader:R,defines:s.defines,customVertexShaderID:L,customFragmentShaderID:D,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:g,instancing:N,instancingColor:N&&null!==_.instanceColor,supportsVertexTextures:m,outputColorSpace:null===P?t.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:pt,map:Q,matcap:F,envMap:O,envMapMode:O&&I.mapping,envMapCubeUVHeight:w,aoMap:k,lightMap:G,bumpMap:H,normalMap:z,displacementMap:m&&V,emissiveMap:W,normalMapObjectSpace:z&&1===s.normalMapType,normalMapTangentSpace:z&&0===s.normalMapType,metalnessMap:q,roughnessMap:X,anisotropy:j,anisotropyMap:Z,clearcoat:Y,clearcoatMap:tt,clearcoatNormalMap:et,clearcoatRoughnessMap:it,iridescence:K,iridescenceMap:nt,iridescenceThicknessMap:rt,sheen:J,sheenColorMap:st,sheenRoughnessMap:at,specularMap:ot,specularColorMap:lt,specularIntensityMap:ct,transmission:$,transmissionMap:ht,thicknessMap:ut,gradientMap:dt,opaque:!1===s.transparent&&1===s.blending,alphaMap:At,alphaTest:mt,alphaHash:gt,combine:s.combine,mapUv:Q&&v(s.map.channel),aoMapUv:k&&v(s.aoMap.channel),lightMapUv:G&&v(s.lightMap.channel),bumpMapUv:H&&v(s.bumpMap.channel),normalMapUv:z&&v(s.normalMap.channel),displacementMapUv:V&&v(s.displacementMap.channel),emissiveMapUv:W&&v(s.emissiveMap.channel),metalnessMapUv:q&&v(s.metalnessMap.channel),roughnessMapUv:X&&v(s.roughnessMap.channel),anisotropyMapUv:Z&&v(s.anisotropyMap.channel),clearcoatMapUv:tt&&v(s.clearcoatMap.channel),clearcoatNormalMapUv:et&&v(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&v(s.clearcoatRoughnessMap.channel),iridescenceMapUv:nt&&v(s.iridescenceMap.channel),iridescenceThicknessMapUv:rt&&v(s.iridescenceThicknessMap.channel),sheenColorMapUv:st&&v(s.sheenColorMap.channel),sheenRoughnessMapUv:at&&v(s.sheenRoughnessMap.channel),specularMapUv:ot&&v(s.specularMap.channel),specularColorMapUv:lt&&v(s.specularColorMap.channel),specularIntensityMapUv:ct&&v(s.specularIntensityMap.channel),transmissionMapUv:ht&&v(s.transmissionMap.channel),thicknessMapUv:ut&&v(s.thicknessMap.channel),alphaMapUv:At&&v(s.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(z||j),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:Et,vertexUv2s:_t,vertexUv3s:yt,pointsUvs:!0===_.isPoints&&!!x.attributes.uv&&(Q||At),fog:!!y,useFog:!0===s.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:A,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:T,morphTextureStride:U,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:t.shadowMap.enabled&&u.length>0,shadowMapType:t.shadowMap.type,toneMapping:xt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Q&&!0===s.map.isVideoTexture&&te.getTransfer(s.map.colorSpace)===vt,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===c,flipSided:s.side===l,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:ft&&!0===s.extensions.derivatives,extensionFragDepth:ft&&!0===s.extensions.fragDepth,extensionDrawBuffers:ft&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:ft&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:d||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||n.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.customVertexShaderID),i.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputColorSpace),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.mapUv),t.push(e.alphaMapUv),t.push(e.lightMapUv),t.push(e.aoMapUv),t.push(e.bumpMapUv),t.push(e.normalMapUv),t.push(e.displacementMapUv),t.push(e.emissiveMapUv),t.push(e.metalnessMapUv),t.push(e.roughnessMapUv),t.push(e.anisotropyMapUv),t.push(e.clearcoatMapUv),t.push(e.clearcoatNormalMapUv),t.push(e.clearcoatRoughnessMapUv),t.push(e.iridescenceMapUv),t.push(e.iridescenceThicknessMapUv),t.push(e.sheenColorMapUv),t.push(e.sheenRoughnessMapUv),t.push(e.specularMapUv),t.push(e.specularColorMapUv),t.push(e.specularIntensityMapUv),t.push(e.transmissionMapUv),t.push(e.thicknessMapUv),t.push(e.combine),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.numLightProbes),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(i,e),function(t,e){o.disableAll(),e.isWebGL2&&o.enable(0);e.supportsVertexTextures&&o.enable(1);e.instancing&&o.enable(2);e.instancingColor&&o.enable(3);e.matcap&&o.enable(4);e.envMap&&o.enable(5);e.normalMapObjectSpace&&o.enable(6);e.normalMapTangentSpace&&o.enable(7);e.clearcoat&&o.enable(8);e.iridescence&&o.enable(9);e.alphaTest&&o.enable(10);e.vertexColors&&o.enable(11);e.vertexAlphas&&o.enable(12);e.vertexUv1s&&o.enable(13);e.vertexUv2s&&o.enable(14);e.vertexUv3s&&o.enable(15);e.vertexTangents&&o.enable(16);e.anisotropy&&o.enable(17);t.push(o.mask),o.disableAll(),e.fog&&o.enable(0);e.useFog&&o.enable(1);e.flatShading&&o.enable(2);e.logarithmicDepthBuffer&&o.enable(3);e.skinning&&o.enable(4);e.morphTargets&&o.enable(5);e.morphNormals&&o.enable(6);e.morphColors&&o.enable(7);e.premultipliedAlpha&&o.enable(8);e.shadowMapEnabled&&o.enable(9);e.useLegacyLights&&o.enable(10);e.doubleSided&&o.enable(11);e.flipSided&&o.enable(12);e.useDepthPacking&&o.enable(13);e.dithering&&o.enable(14);e.transmission&&o.enable(15);e.sheen&&o.enable(16);e.opaque&&o.enable(17);e.pointsUvs&&o.enable(18);e.decodeVideoTexture&&o.enable(19);t.push(o.mask)}(i,e),i.push(t.outputColorSpace)),i.push(e.customProgramCacheKey),i.join()},getUniforms:function(t){const e=f[t.type];let i;if(e){const t=qn[e];i=wn.clone(t.uniforms)}else i=t.uniforms;return i},acquireProgram:function(e,i){let n;for(let t=0,e=u.length;t0?n.push(h):!0===a.transparent?r.push(h):i.push(h)},unshift:function(t,e,a,o,l,c){const h=s(t,e,a,o,l,c);a.transmission>0?n.unshift(h):!0===a.transparent?r.unshift(h):i.unshift(h)},finish:function(){for(let i=e,n=t.length;i1&&i.sort(t||Ks),n.length>1&&n.sort(e||Js),r.length>1&&r.sort(e||Js)}}}function Zs(){let t=new WeakMap;return{get:function(e,i){const n=t.get(e);let r;return void 0===n?(r=new $s,t.set(e,[r])):i>=n.length?(r=new $s,n.push(r)):r=n[i],r},dispose:function(){t=new WeakMap}}}function ta(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new ge,color:new Ni};break;case"SpotLight":i={position:new ge,direction:new ge,color:new Ni,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new ge,color:new Ni,distance:0,decay:0};break;case"HemisphereLight":i={direction:new ge,skyColor:new Ni,groundColor:new Ni};break;case"RectAreaLight":i={color:new Ni,position:new ge,halfWidth:new ge,halfHeight:new ge}}return t[e.id]=i,i}}}let ea=0;function ia(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function na(t,e){const i=new ta,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ht};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ht,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let t=0;t<9;t++)r.probe.push(new ge);const s=new ge,a=new qe,o=new qe;return{setup:function(s,a){let o=0,l=0,c=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let h=0,u=0,d=0,A=0,p=0,m=0,g=0,f=0,v=0,E=0,_=0;s.sort(ia);const y=!0===a?Math.PI:1;for(let t=0,e=s.length;t0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=Wn.LTC_FLOAT_1,r.rectAreaLTC2=Wn.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Wn.LTC_HALF_1,r.rectAreaLTC2=Wn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const x=r.hash;x.directionalLength===h&&x.pointLength===u&&x.spotLength===d&&x.rectAreaLength===A&&x.hemiLength===p&&x.numDirectionalShadows===m&&x.numPointShadows===g&&x.numSpotShadows===f&&x.numSpotMaps===v&&x.numLightProbes===_||(r.directional.length=h,r.spot.length=d,r.rectArea.length=A,r.point.length=u,r.hemi.length=p,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=f,r.spotShadowMap.length=f,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=f+v-E,r.spotLightMap.length=v,r.numSpotLightShadowsWithMaps=E,r.numLightProbes=_,x.directionalLength=h,x.pointLength=u,x.spotLength=d,x.rectAreaLength=A,x.hemiLength=p,x.numDirectionalShadows=m,x.numPointShadows=g,x.numSpotShadows=f,x.numSpotMaps=v,x.numLightProbes=_,r.version=ea++)},setupView:function(t,e){let i=0,n=0,l=0,c=0,h=0;const u=e.matrixWorldInverse;for(let e=0,d=t.length;e=s.length?(a=new ra(t,e),s.push(a)):a=s[r],a},dispose:function(){i=new WeakMap}}}class aa extends Ri{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class oa extends Ri{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function la(t,e,i){let n=new kn;const s=new Ht,h=new Ht,u=new he,d=new aa({depthPacking:3201}),A=new oa,p={},m=i.maxTextureSize,g={[o]:l,[l]:o,[c]:c},f=new Mn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ht},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),v=f.clone();v.defines.HORIZONTAL_PASS=1;const E=new en;E.setAttribute("position",new Vi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new _n(E,f),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=r;let x=this.type;function S(i,n){const r=e.update(_);f.defines.VSM_SAMPLES!==i.blurSamples&&(f.defines.VSM_SAMPLES=i.blurSamples,v.defines.VSM_SAMPLES=i.blurSamples,f.needsUpdate=!0,v.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new de(s.x,s.y)),f.uniforms.shadow_pass.value=i.map.texture,f.uniforms.resolution.value=i.mapSize,f.uniforms.radius.value=i.radius,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,f,_,null),v.uniforms.shadow_pass.value=i.mapPass.texture,v.uniforms.resolution.value=i.mapSize,v.uniforms.radius.value=i.radius,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,v,_,null)}function C(e,i,n,r){let s=null;const o=!0===n.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(void 0!==o)s=o;else if(s=!0===n.isPointLight?A:d,t.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){const t=s.uuid,e=i.uuid;let n=p[t];void 0===n&&(n={},p[t]=n);let r=n[e];void 0===r&&(r=s.clone(),n[e]=r),s=r}if(s.visible=i.visible,s.wireframe=i.wireframe,s.side=r===a?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:g[i.side],s.alphaMap=i.alphaMap,s.alphaTest=i.alphaTest,s.map=i.map,s.clipShadows=i.clipShadows,s.clippingPlanes=i.clippingPlanes,s.clipIntersection=i.clipIntersection,s.displacementMap=i.displacementMap,s.displacementScale=i.displacementScale,s.displacementBias=i.displacementBias,s.wireframeLinewidth=i.wireframeLinewidth,s.linewidth=i.linewidth,!0===n.isPointLight&&!0===s.isMeshDistanceMaterial){t.properties.get(s).light=n}return s}function I(i,r,s,o,l){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&l===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,i.matrixWorld);const n=e.update(i),r=i.material;if(Array.isArray(r)){const e=n.groups;for(let a=0,c=e.length;am||s.y>m)&&(s.x>m&&(h.x=Math.floor(m/g.x),s.x=h.x*g.x,c.mapSize.x=h.x),s.y>m&&(h.y=Math.floor(m/g.y),s.y=h.y*g.y,c.mapSize.y=h.y)),null===c.map||!0===A||!0===p){const t=this.type!==a?{minFilter:M,magFilter:M}:{};null!==c.map&&c.map.dispose(),c.map=new de(s.x,s.y,t),c.map.texture.name=l.name+".shadowMap",c.camera.updateProjectionMatrix()}t.setRenderTarget(c.map),t.clear();const f=c.getViewportCount();for(let t=0;t=1):-1!==U.indexOf("OpenGL ES")&&(D=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),L=D>=2);let P=null,N={};const Q=t.getParameter(t.SCISSOR_BOX),F=t.getParameter(t.VIEWPORT),O=(new he).fromArray(Q),k=(new he).fromArray(F);function G(e,i,r,s){const a=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let o=0;on||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?Ft:Math.floor,s=n(r*t.width),a=n(r*t.height);void 0===m&&(m=v(s,a));const o=i?v(s,a):m;o.width=s,o.height=a;return o.getContext("2d").drawImage(t,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+s+"x"+a+")."),o}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function _(t){return Nt(t.width)&&Nt(t.height)}function y(t,e){return t.generateMipmaps&&e&&t.minFilter!==M&&t.minFilter!==B}function x(e){t.generateMipmap(e)}function S(i,n,r,s,a=!1){if(!1===o)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l=n;if(n===t.RED&&(r===t.FLOAT&&(l=t.R32F),r===t.HALF_FLOAT&&(l=t.R16F),r===t.UNSIGNED_BYTE&&(l=t.R8)),n===t.RED_INTEGER&&(r===t.UNSIGNED_BYTE&&(l=t.R8UI),r===t.UNSIGNED_SHORT&&(l=t.R16UI),r===t.UNSIGNED_INT&&(l=t.R32UI),r===t.BYTE&&(l=t.R8I),r===t.SHORT&&(l=t.R16I),r===t.INT&&(l=t.R32I)),n===t.RG&&(r===t.FLOAT&&(l=t.RG32F),r===t.HALF_FLOAT&&(l=t.RG16F),r===t.UNSIGNED_BYTE&&(l=t.RG8)),n===t.RGBA){const e=a?ft:te.getTransfer(s);r===t.FLOAT&&(l=t.RGBA32F),r===t.HALF_FLOAT&&(l=t.RGBA16F),r===t.UNSIGNED_BYTE&&(l=e===vt?t.SRGB8_ALPHA8:t.RGBA8),r===t.UNSIGNED_SHORT_4_4_4_4&&(l=t.RGBA4),r===t.UNSIGNED_SHORT_5_5_5_1&&(l=t.RGB5_A1)}return l!==t.R16F&&l!==t.R32F&&l!==t.RG16F&&l!==t.RG32F&&l!==t.RGBA16F&&l!==t.RGBA32F||e.get("EXT_color_buffer_float"),l}function P(t,e,i){return!0===y(t,i)||t.isFramebufferTexture&&t.minFilter!==M&&t.minFilter!==B?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function z(e){return e===M||e===b||e===T?t.NEAREST:t.LINEAR}function V(t){const e=t.target;e.removeEventListener("dispose",V),function(t){const e=n.get(t);if(void 0===e.__webglInit)return;const i=t.source,r=g.get(i);if(r){const n=r[e.__cacheKey];n.usedTimes--,0===n.usedTimes&&q(t),0===Object.keys(r).length&&g.delete(i)}n.remove(t)}(e),e.isVideoTexture&&p.delete(e)}function W(e){const i=e.target;i.removeEventListener("dispose",W),function(e){const i=e.texture,r=n.get(e),s=n.get(i);void 0!==s.__webglTexture&&(t.deleteTexture(s.__webglTexture),a.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++){if(Array.isArray(r.__webglFramebuffer[e]))for(let i=0;i0&&s.__version!==e.version){const t=e.image;if(null===t)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==t.complete)return void tt(s,e,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(t.TEXTURE_2D,s.__webglTexture,t.TEXTURE0+r)}const Y={[C]:t.REPEAT,[I]:t.CLAMP_TO_EDGE,[w]:t.MIRRORED_REPEAT},K={[M]:t.NEAREST,[b]:t.NEAREST_MIPMAP_NEAREST,[T]:t.NEAREST_MIPMAP_LINEAR,[B]:t.LINEAR,[R]:t.LINEAR_MIPMAP_NEAREST,[L]:t.LINEAR_MIPMAP_LINEAR},J={512:t.NEVER,519:t.ALWAYS,513:t.LESS,515:t.LEQUAL,514:t.EQUAL,518:t.GEQUAL,516:t.GREATER,517:t.NOTEQUAL};function $(i,s,a){if(a?(t.texParameteri(i,t.TEXTURE_WRAP_S,Y[s.wrapS]),t.texParameteri(i,t.TEXTURE_WRAP_T,Y[s.wrapT]),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,Y[s.wrapR]),t.texParameteri(i,t.TEXTURE_MAG_FILTER,K[s.magFilter]),t.texParameteri(i,t.TEXTURE_MIN_FILTER,K[s.minFilter])):(t.texParameteri(i,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(i,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),i!==t.TEXTURE_3D&&i!==t.TEXTURE_2D_ARRAY||t.texParameteri(i,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),s.wrapS===I&&s.wrapT===I||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(i,t.TEXTURE_MAG_FILTER,z(s.magFilter)),t.texParameteri(i,t.TEXTURE_MIN_FILTER,z(s.minFilter)),s.minFilter!==M&&s.minFilter!==B&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(t.texParameteri(i,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(i,t.TEXTURE_COMPARE_FUNC,J[s.compareFunction])),!0===e.has("EXT_texture_filter_anisotropic")){const a=e.get("EXT_texture_filter_anisotropic");if(s.magFilter===M)return;if(s.minFilter!==T&&s.minFilter!==L)return;if(s.type===Q&&!1===e.has("OES_texture_float_linear"))return;if(!1===o&&s.type===F&&!1===e.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||n.get(s).__currentAnisotropy)&&(t.texParameterf(i,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),n.get(s).__currentAnisotropy=s.anisotropy)}}function Z(e,i){let n=!1;void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",V));const r=i.source;let s=g.get(r);void 0===s&&(s={},g.set(r,s));const o=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.colorSpace),e.join()}(i);if(o!==e.__cacheKey){void 0===s[o]&&(s[o]={texture:t.createTexture(),usedTimes:0},a.memory.textures++,n=!0),s[o].usedTimes++;const r=s[e.__cacheKey];void 0!==r&&(s[e.__cacheKey].usedTimes--,0===r.usedTimes&&q(i)),e.__cacheKey=o,e.__webglTexture=s[o].texture}return n}function tt(e,r,a){let l=t.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=t.TEXTURE_2D_ARRAY),r.isData3DTexture&&(l=t.TEXTURE_3D);const c=Z(e,r),u=r.source;i.bindTexture(l,e.__webglTexture,t.TEXTURE0+a);const d=n.get(u);if(u.version!==d.__version||!0===c){i.activeTexture(t.TEXTURE0+a);const e=te.getPrimaries(te.workingColorSpace),n=r.colorSpace===dt?null:te.getPrimaries(r.colorSpace),A=r.colorSpace===dt||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,A);const p=function(t){return!o&&(t.wrapS!==I||t.wrapT!==I||t.minFilter!==M&&t.minFilter!==B)}(r)&&!1===_(r.image);let m=E(r.image,p,!1,h);m=at(r,m);const g=_(m)||o,f=s.convert(r.format,r.colorSpace);let v,C=s.convert(r.type),w=S(r.internalFormat,f,C,r.colorSpace,r.isVideoTexture);$(l,r,g);const b=r.mipmaps,T=o&&!0!==r.isVideoTexture,R=void 0===d.__version||!0===c,L=P(r,m,g);if(r.isDepthTexture)w=t.DEPTH_COMPONENT,o?w=r.type===Q?t.DEPTH_COMPONENT32F:r.type===N?t.DEPTH_COMPONENT24:r.type===O?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT16:r.type===Q&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===G&&w===t.DEPTH_COMPONENT&&r.type!==U&&r.type!==N&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=N,C=s.convert(r.type)),r.format===H&&w===t.DEPTH_COMPONENT&&(w=t.DEPTH_STENCIL,r.type!==O&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=O,C=s.convert(r.type))),R&&(T?i.texStorage2D(t.TEXTURE_2D,1,w,m.width,m.height):i.texImage2D(t.TEXTURE_2D,0,w,m.width,m.height,0,f,C,null));else if(r.isDataTexture)if(b.length>0&&g){T&&R&&i.texStorage2D(t.TEXTURE_2D,L,w,b[0].width,b[0].height);for(let e=0,n=b.length;e>=1,n>>=1}}else if(b.length>0&&g){T&&R&&i.texStorage2D(t.TEXTURE_2D,L,w,b[0].width,b[0].height);for(let e=0,n=b.length;e>c),n=Math.max(1,r.height>>c);l===t.TEXTURE_3D||l===t.TEXTURE_2D_ARRAY?i.texImage3D(l,c,A,e,n,r.depth,0,h,u,null):i.texImage2D(l,c,A,e,n,0,h,u,null)}i.bindFramebuffer(t.FRAMEBUFFER,e),st(r)?d.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,o,l,n.get(a).__webglTexture,0,rt(r)):(l===t.TEXTURE_2D||l>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,o,l,n.get(a).__webglTexture,c),i.bindFramebuffer(t.FRAMEBUFFER,null)}function it(e,i,n){if(t.bindRenderbuffer(t.RENDERBUFFER,e),i.depthBuffer&&!i.stencilBuffer){let r=!0===o?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(n||st(i)){const e=i.depthTexture;e&&e.isDepthTexture&&(e.type===Q?r=t.DEPTH_COMPONENT32F:e.type===N&&(r=t.DEPTH_COMPONENT24));const n=rt(i);st(i)?d.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,n,r,i.width,i.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,n,r,i.width,i.height)}else t.renderbufferStorage(t.RENDERBUFFER,r,i.width,i.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)}else if(i.depthBuffer&&i.stencilBuffer){const r=rt(i);n&&!1===st(i)?t.renderbufferStorageMultisample(t.RENDERBUFFER,r,t.DEPTH24_STENCIL8,i.width,i.height):st(i)?d.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,r,t.DEPTH24_STENCIL8,i.width,i.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,i.width,i.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)}else{const e=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let r=0;r0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function at(t,i){const n=t.colorSpace,r=t.format,s=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||t.format===Ct||n!==pt&&n!==dt&&(te.getTransfer(n)===vt?!1===o?!0===e.has("EXT_sRGB")&&r===k?(t.format=Ct,t.minFilter=B,t.generateMipmaps=!1):i=re.sRGBToLinear(i):r===k&&s===D||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),i}this.allocateTextureUnit=function(){const t=X;return t>=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),X+=1,t},this.resetTextureUnits=function(){X=0},this.setTexture2D=j,this.setTexture2DArray=function(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?tt(s,e,r):i.bindTexture(t.TEXTURE_2D_ARRAY,s.__webglTexture,t.TEXTURE0+r)},this.setTexture3D=function(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?tt(s,e,r):i.bindTexture(t.TEXTURE_3D,s.__webglTexture,t.TEXTURE0+r)},this.setTextureCube=function(e,r){const a=n.get(e);e.version>0&&a.__version!==e.version?function(e,r,a){if(6!==r.image.length)return;const l=Z(e,r),h=r.source;i.bindTexture(t.TEXTURE_CUBE_MAP,e.__webglTexture,t.TEXTURE0+a);const u=n.get(h);if(h.version!==u.__version||!0===l){i.activeTexture(t.TEXTURE0+a);const e=te.getPrimaries(te.workingColorSpace),n=r.colorSpace===dt?null:te.getPrimaries(r.colorSpace),d=r.colorSpace===dt||e===n?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const A=r.isCompressedTexture||r.image[0].isCompressedTexture,p=r.image[0]&&r.image[0].isDataTexture,m=[];for(let t=0;t<6;t++)m[t]=A||p?p?r.image[t].image:r.image[t]:E(r.image[t],!1,!0,c),m[t]=at(r,m[t]);const g=m[0],f=_(g)||o,v=s.convert(r.format,r.colorSpace),C=s.convert(r.type),I=S(r.internalFormat,v,C,r.colorSpace),w=o&&!0!==r.isVideoTexture,M=void 0===u.__version||!0===l;let b,T=P(r,g,f);if($(t.TEXTURE_CUBE_MAP,r,f),A){w&&M&&i.texStorage2D(t.TEXTURE_CUBE_MAP,T,I,g.width,g.height);for(let e=0;e<6;e++){b=m[e].mipmaps;for(let n=0;n0&&T++,i.texStorage2D(t.TEXTURE_CUBE_MAP,T,I,m[0].width,m[0].height));for(let e=0;e<6;e++)if(p){w?i.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,m[e].width,m[e].height,v,C,m[e].data):i.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,I,m[e].width,m[e].height,0,v,C,m[e].data);for(let n=0;n0){c.__webglFramebuffer[e]=[];for(let i=0;i0){c.__webglFramebuffer=[];for(let e=0;e0&&!1===st(e)){const n=d?l:[l];c.__webglMultisampledFramebuffer=t.createFramebuffer(),c.__webglColorRenderbuffer=[],i.bindFramebuffer(t.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let i=0;i0)for(let n=0;n0)for(let i=0;i0&&!1===st(e)){const r=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],s=e.width,a=e.height;let o=t.COLOR_BUFFER_BIT;const l=[],c=e.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,h=n.get(e),u=!0===e.isWebGLMultipleRenderTargets;if(u)for(let e=0;eo+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(n=e.getPose(t.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(a.matrix.fromArray(n.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,n.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(n.linearVelocity)):a.hasLinearVelocity=!1,n.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(n.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(pa)))}return null!==a&&(a.visible=null!==n),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){const i=new Aa;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class ga extends ce{constructor(t,e,i,n,r,s,a,o,l,c){if((c=void 0!==c?c:G)!==G&&c!==H)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===G&&(i=N),void 0===i&&c===H&&(i=O),super(null,n,r,s,a,o,c,i,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==a?a:M,this.minFilter=void 0!==o?o:M,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class fa extends Mt{constructor(t,e){super();const i=this;let n=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,A=null;const p=e.getContextAttributes();let m=null,g=null;const f=[],v=[],E=new Tn;E.layers.enable(1),E.viewport=new he;const _=new Tn;_.layers.enable(2),_.viewport=new he;const y=[E,_],x=new da;x.layers.enable(1),x.layers.enable(2);let S=null,C=null;function I(t){const e=v.indexOf(t.inputSource);if(-1===e)return;const i=f[e];void 0!==i&&(i.update(t.inputSource,t.frame,l||s),i.dispatchEvent({type:t.type,data:t.inputSource}))}function w(){n.removeEventListener("select",I),n.removeEventListener("selectstart",I),n.removeEventListener("selectend",I),n.removeEventListener("squeeze",I),n.removeEventListener("squeezestart",I),n.removeEventListener("squeezeend",I),n.removeEventListener("end",w),n.removeEventListener("inputsourceschange",M);for(let t=0;t=0&&(v[n]=null,f[n].disconnect(i))}for(let e=0;e=v.length){v.push(i),n=t;break}if(null===v[t]){v[t]=i,n=t;break}}if(-1===n)break}const r=f[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=f[t];return void 0===e&&(e=new ma,f[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=f[t];return void 0===e&&(e=new ma,f[t]=e),e.getGripSpace()},this.getHand=function(t){let e=f[t];return void 0===e&&(e=new ma,f[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){r=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){a=t,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(t){l=t},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return A},this.getSession=function(){return n},this.setSession=async function(c){if(n=c,null!==n){if(m=t.getRenderTarget(),n.addEventListener("select",I),n.addEventListener("selectstart",I),n.addEventListener("selectend",I),n.addEventListener("squeeze",I),n.addEventListener("squeezestart",I),n.addEventListener("squeezeend",I),n.addEventListener("end",w),n.addEventListener("inputsourceschange",M),!0!==p.xrCompatible&&await e.makeXRCompatible(),void 0===n.renderState.layers||!1===t.capabilities.isWebGL2){const i={antialias:void 0!==n.renderState.layers||p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(n,e,i),n.updateRenderState({baseLayer:d}),g=new de(d.framebufferWidth,d.framebufferHeight,{format:k,type:D,colorSpace:t.outputColorSpace,stencilBuffer:p.stencil})}else{let i=null,s=null,a=null;p.depth&&(a=p.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,i=p.stencil?H:G,s=p.stencil?O:N);const o={colorFormat:e.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(n,e),u=h.createProjectionLayer(o),n.updateRenderState({layers:[u]}),g=new de(u.textureWidth,u.textureHeight,{format:k,type:D,depthTexture:new ga(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:p.stencil,colorSpace:t.outputColorSpace,samples:p.antialias?4:0});t.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await n.requestReferenceSpace(a),L.setContext(n),L.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode};const b=new ge,T=new ge;function B(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===n)return;x.near=_.near=E.near=t.near,x.far=_.far=E.far=t.far,S===x.near&&C===x.far||(n.updateRenderState({depthNear:x.near,depthFar:x.far}),S=x.near,C=x.far);const e=t.parent,i=x.cameras;B(x,e);for(let t=0;t0&&(n.alphaTest.value=r.alphaTest);const s=e.get(r).envMap;if(s&&(n.envMap.value=s,n.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;const e=!0===t._useLegacyLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*e,i(r.lightMap,n.lightMapTransform)}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,i(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(e,i){i.color.getRGB(e.fogColor.value,In(t)),i.isFog?(e.fogNear.value=i.near,e.fogFar.value=i.far):i.isFogExp2&&(e.fogDensity.value=i.density)},refreshMaterialUniforms:function(t,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(t,r):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(n(t,r),function(t,n){t.metalness.value=n.metalness,n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap,i(n.metalnessMap,t.metalnessMapTransform));t.roughness.value=n.roughness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap,i(n.roughnessMap,t.roughnessMapTransform));const r=e.get(n).envMap;r&&(t.envMapIntensity.value=n.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap,i(e.sheenColorMap,t.sheenColorMapTransform)),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap,i(e.sheenRoughnessMap,t.sheenRoughnessMapTransform)));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap,i(e.clearcoatMap,t.clearcoatMapTransform)),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap,i(e.clearcoatRoughnessMap,t.clearcoatRoughnessMapTransform)),e.clearcoatNormalMap&&(t.clearcoatNormalMap.value=e.clearcoatNormalMap,i(e.clearcoatNormalMap,t.clearcoatNormalMapTransform),t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),e.side===l&&t.clearcoatNormalScale.value.negate()));e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap,i(e.iridescenceMap,t.iridescenceMapTransform)),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap,i(e.iridescenceThicknessMap,t.iridescenceThicknessMapTransform)));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap,i(e.transmissionMap,t.transmissionMapTransform)),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap,i(e.thicknessMap,t.thicknessMapTransform)),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));e.anisotropy>0&&(t.anisotropyVector.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation)),e.anisotropyMap&&(t.anisotropyMap.value=e.anisotropyMap,i(e.anisotropyMap,t.anisotropyMapTransform)));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap,i(e.specularColorMap,t.specularColorMapTransform));e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap,i(e.specularIntensityMap,t.specularIntensityMapTransform))}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,i){const n=e.get(i).light;t.referencePosition.value.setFromMatrixPosition(n.matrixWorld),t.nearDistance.value=n.shadow.camera.near,t.farDistance.value=n.shadow.camera.far}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform))}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map,i(e.map,t.uvTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r,s,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map,i(e.map,t.mapTransform));e.alphaMap&&(t.alphaMap.value=e.alphaMap,i(e.alphaMap,t.alphaMapTransform));e.alphaTest>0&&(t.alphaTest.value=e.alphaTest)}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Ea(t,e,i,n){let r={},s={},a=[];const o=i.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(t,e,i){const n=t.value;if(void 0===i[e]){if("number"==typeof n)i[e]=n;else{const t=Array.isArray(n)?n:[n],r=[];for(let e=0;e0){r=i%n;0!==r&&n-r-a.boundary<0&&(i+=n-r,s.__offset=i)}i+=a.storage}r=i%n,r>0&&(i+=n-r);t.__size=i,t.__cache={}}(i),d=function(e){const i=function(){for(let t=0;t0),u=!!i.morphAttributes.position,d=!!i.morphAttributes.normal,A=!!i.morphAttributes.color;let m=p;n.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(m=S.toneMapping));const g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,f=void 0!==g?g.length:0,v=ht.get(n),E=_.state.lights;if(!0===$&&(!0===Z||t!==T)){const e=t===T&&n.id===b;St.setState(n,t,e)}let y=!1;n.version===v.__version?v.needsLights&&v.lightsStateVersion!==E.state.version||v.outputColorSpace!==o||r.isInstancedMesh&&!1===v.instancing?y=!0:r.isInstancedMesh||!0!==v.instancing?r.isSkinnedMesh&&!1===v.skinning?y=!0:r.isSkinnedMesh||!0!==v.skinning?r.isInstancedMesh&&!0===v.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===v.instancingColor&&null!==r.instanceColor||v.envMap!==l||!0===n.fog&&v.fog!==s?y=!0:void 0===v.numClippingPlanes||v.numClippingPlanes===St.numPlanes&&v.numIntersection===St.numIntersection?(v.vertexAlphas!==c||v.vertexTangents!==h||v.morphTargets!==u||v.morphNormals!==d||v.morphColors!==A||v.toneMapping!==m||!0===ot.isWebGL2&&v.morphTargetsCount!==f)&&(y=!0):y=!0:y=!0:y=!0:(y=!0,v.__version=n.version);let x=v.currentProgram;!0===y&&(x=Jt(n,e,r));let C=!1,I=!1,w=!1;const B=x.getUniforms(),R=v.uniforms;lt.useProgram(x.program)&&(C=!0,I=!0,w=!0);n.id!==b&&(b=n.id,I=!0);if(C||T!==t){B.setValue(Lt,"projectionMatrix",t.projectionMatrix),B.setValue(Lt,"viewMatrix",t.matrixWorldInverse);const e=B.map.cameraPosition;void 0!==e&&e.setValue(Lt,nt.setFromMatrixPosition(t.matrixWorld)),ot.logarithmicDepthBuffer&&B.setValue(Lt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&B.setValue(Lt,"isOrthographic",!0===t.isOrthographicCamera),T!==t&&(T=t,I=!0,w=!0)}if(r.isSkinnedMesh){B.setOptional(Lt,r,"bindMatrix"),B.setOptional(Lt,r,"bindMatrixInverse");const t=r.skeleton;t&&(ot.floatVertexTextures?(null===t.boneTexture&&t.computeBoneTexture(),B.setValue(Lt,"boneTexture",t.boneTexture,ut),B.setValue(Lt,"boneTextureSize",t.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const L=i.morphAttributes;(void 0!==L.position||void 0!==L.normal||void 0!==L.color&&!0===ot.isWebGL2)&&wt.update(r,i,x);(I||v.receiveShadow!==r.receiveShadow)&&(v.receiveShadow=r.receiveShadow,B.setValue(Lt,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);I&&(B.setValue(Lt,"toneMappingExposure",S.toneMappingExposure),v.needsLights&&(U=w,(D=R).ambientLightColor.needsUpdate=U,D.lightProbe.needsUpdate=U,D.directionalLights.needsUpdate=U,D.directionalLightShadows.needsUpdate=U,D.pointLights.needsUpdate=U,D.pointLightShadows.needsUpdate=U,D.spotLights.needsUpdate=U,D.spotLightShadows.needsUpdate=U,D.rectAreaLights.needsUpdate=U,D.hemisphereLights.needsUpdate=U),s&&!0===n.fog&&_t.refreshFogUniforms(R,s),_t.refreshMaterialUniforms(R,n,W,V,tt),Ms.upload(Lt,v.uniformsList,R,ut));var D,U;n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Ms.upload(Lt,v.uniformsList,R,ut),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&B.setValue(Lt,"center",r.center);if(B.setValue(Lt,"modelViewMatrix",r.modelViewMatrix),B.setValue(Lt,"normalMatrix",r.normalMatrix),B.setValue(Lt,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const t=n.uniformsGroups;for(let e=0,i=t.length;e0&&function(t,e,i,n){const r=ot.isWebGL2;null===tt&&(tt=new de(1,1,{generateMipmaps:!0,type:at.has("EXT_color_buffer_half_float")?F:D,minFilter:L,samples:r?4:0}));S.getDrawingBufferSize(it),r?tt.setSize(it.x,it.y):tt.setSize(Ft(it.x),Ft(it.y));const s=S.getRenderTarget();S.setRenderTarget(tt),S.getClearColor(G),H=S.getClearAlpha(),H<1&&S.setClearColor(16777215,.5);S.clear();const a=S.toneMapping;S.toneMapping=p,Yt(t,i,n),ut.updateMultisampleRenderTarget(tt),ut.updateRenderTargetMipmap(tt);let o=!1;for(let t=0,r=e.length;t0&&Yt(r,e,i),s.length>0&&Yt(s,e,i),a.length>0&&Yt(a,e,i),lt.buffers.depth.setTest(!0),lt.buffers.depth.setMask(!0),lt.buffers.color.setMask(!0),lt.setPolygonOffset(!1)}function Yt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,s=t.length;r0?x[x.length-1]:null,y.pop(),E=y.length>0?y[y.length-1]:null},this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(t,e,i){ht.get(t.texture).__webglTexture=e,ht.get(t.depthTexture).__webglTexture=i;const n=ht.get(t);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===at.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),n.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(t,e){const i=ht.get(t);i.__webglFramebuffer=e,i.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,i=0){M=t,I=e,w=i;let n=!0,r=null,s=!1,a=!1;if(t){const o=ht.get(t);void 0!==o.__useDefaultFramebuffer?(lt.bindFramebuffer(Lt.FRAMEBUFFER,null),n=!1):void 0===o.__webglFramebuffer?ut.setupRenderTarget(t):o.__hasExternalTextures&&ut.rebindTextures(t,ht.get(t.texture).__webglTexture,ht.get(t.depthTexture).__webglTexture);const l=t.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(a=!0);const c=ht.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(r=Array.isArray(c[e])?c[e][i]:c[e],s=!0):r=ot.isWebGL2&&t.samples>0&&!1===ut.useMultisampledRTT(t)?ht.get(t).__webglMultisampledFramebuffer:Array.isArray(c)?c[i]:c,B.copy(t.viewport),R.copy(t.scissor),P=t.scissorTest}else B.copy(j).multiplyScalar(W).floor(),R.copy(Y).multiplyScalar(W).floor(),P=K;if(lt.bindFramebuffer(Lt.FRAMEBUFFER,r)&&ot.drawBuffers&&n&<.drawBuffers(t,r),lt.viewport(B),lt.scissor(R),lt.setScissorTest(P),s){const n=ht.get(t.texture);Lt.framebufferTexture2D(Lt.FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,Lt.TEXTURE_CUBE_MAP_POSITIVE_X+e,n.__webglTexture,i)}else if(a){const n=ht.get(t.texture),r=e||0;Lt.framebufferTextureLayer(Lt.FRAMEBUFFER,Lt.COLOR_ATTACHMENT0,n.__webglTexture,i||0,r)}b=-1},this.readRenderTargetPixels=function(t,e,i,n,r,s,a){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ht.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){lt.bindFramebuffer(Lt.FRAMEBUFFER,o);try{const a=t.texture,o=a.format,l=a.type;if(o!==k&&Tt.convert(o)!==Lt.getParameter(Lt.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===F&&(at.has("EXT_color_buffer_half_float")||ot.isWebGL2&&at.has("EXT_color_buffer_float"));if(!(l===D||Tt.convert(l)===Lt.getParameter(Lt.IMPLEMENTATION_COLOR_READ_TYPE)||l===Q&&(ot.isWebGL2||at.has("OES_texture_float")||at.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&Lt.readPixels(e,i,n,r,Tt.convert(o),Tt.convert(l),s)}finally{const t=null!==M?ht.get(M).__webglFramebuffer:null;lt.bindFramebuffer(Lt.FRAMEBUFFER,t)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),r=Math.floor(e.image.width*n),s=Math.floor(e.image.height*n);ut.setTexture2D(e,0),Lt.copyTexSubImage2D(Lt.TEXTURE_2D,i,0,0,t.x,t.y,r,s),lt.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const r=e.image.width,s=e.image.height,a=Tt.convert(i.format),o=Tt.convert(i.type);ut.setTexture2D(i,0),Lt.pixelStorei(Lt.UNPACK_FLIP_Y_WEBGL,i.flipY),Lt.pixelStorei(Lt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Lt.pixelStorei(Lt.UNPACK_ALIGNMENT,i.unpackAlignment),e.isDataTexture?Lt.texSubImage2D(Lt.TEXTURE_2D,n,t.x,t.y,r,s,a,o,e.image.data):e.isCompressedTexture?Lt.compressedTexSubImage2D(Lt.TEXTURE_2D,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,a,e.mipmaps[0].data):Lt.texSubImage2D(Lt.TEXTURE_2D,n,t.x,t.y,a,o,e.image),0===n&&i.generateMipmaps&&Lt.generateMipmap(Lt.TEXTURE_2D),lt.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i,n,r=0){if(S.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=t.max.x-t.min.x+1,a=t.max.y-t.min.y+1,o=t.max.z-t.min.z+1,l=Tt.convert(n.format),c=Tt.convert(n.type);let h;if(n.isData3DTexture)ut.setTexture3D(n,0),h=Lt.TEXTURE_3D;else{if(!n.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");ut.setTexture2DArray(n,0),h=Lt.TEXTURE_2D_ARRAY}Lt.pixelStorei(Lt.UNPACK_FLIP_Y_WEBGL,n.flipY),Lt.pixelStorei(Lt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Lt.pixelStorei(Lt.UNPACK_ALIGNMENT,n.unpackAlignment);const u=Lt.getParameter(Lt.UNPACK_ROW_LENGTH),d=Lt.getParameter(Lt.UNPACK_IMAGE_HEIGHT),A=Lt.getParameter(Lt.UNPACK_SKIP_PIXELS),p=Lt.getParameter(Lt.UNPACK_SKIP_ROWS),m=Lt.getParameter(Lt.UNPACK_SKIP_IMAGES),g=i.isCompressedTexture?i.mipmaps[0]:i.image;Lt.pixelStorei(Lt.UNPACK_ROW_LENGTH,g.width),Lt.pixelStorei(Lt.UNPACK_IMAGE_HEIGHT,g.height),Lt.pixelStorei(Lt.UNPACK_SKIP_PIXELS,t.min.x),Lt.pixelStorei(Lt.UNPACK_SKIP_ROWS,t.min.y),Lt.pixelStorei(Lt.UNPACK_SKIP_IMAGES,t.min.z),i.isDataTexture||i.isData3DTexture?Lt.texSubImage3D(h,r,e.x,e.y,e.z,s,a,o,l,c,g.data):i.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Lt.compressedTexSubImage3D(h,r,e.x,e.y,e.z,s,a,o,l,g.data)):Lt.texSubImage3D(h,r,e.x,e.y,e.z,s,a,o,l,c,g),Lt.pixelStorei(Lt.UNPACK_ROW_LENGTH,u),Lt.pixelStorei(Lt.UNPACK_IMAGE_HEIGHT,d),Lt.pixelStorei(Lt.UNPACK_SKIP_PIXELS,A),Lt.pixelStorei(Lt.UNPACK_SKIP_ROWS,p),Lt.pixelStorei(Lt.UNPACK_SKIP_IMAGES,m),0===r&&n.generateMipmaps&&Lt.generateMipmap(h),lt.unbindTexture()},this.initTexture=function(t){t.isCubeTexture?ut.setTextureCube(t,0):t.isData3DTexture?ut.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?ut.setTexture2DArray(t,0):ut.setTexture2D(t,0),lt.unbindTexture()},this.resetState=function(){I=0,w=0,M=null,lt.reset(),Bt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return It}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===mt?"display-p3":"srgb",e.unpackColorSpace=te.workingColorSpace===gt?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===At?ut:3e3}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===ut?At:pt}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}}(class extends _a{}).prototype.isWebGL1Renderer=!0;class ya extends fi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e}}class xa{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=xt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Lt()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;no)continue;u.applyMatrix4(this.matrixWorld);const s=t.ray.origin.distanceTo(u);st.far||e.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{for(let i=Math.max(0,s.start),n=Math.min(p.count,s.start+s.count)-1;io)continue;u.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(u);nt.far||e.push({distance:n,point:h.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t0){const i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;tr.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,object:a})}}class po extends ce{constructor(t,e,i,n,r,s,a,o,l){super(t,e,i,n,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:B,this.magFilter=void 0!==r?r:B,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.needsUpdate=!0,t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;!1==="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class mo extends ce{constructor(t,e,i,n,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,n,r,h,u),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class go extends mo{constructor(t,e,i,n,r,s){super(t,e,i,r,s),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=I}}class fo extends mo{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,_),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class vo extends ce{constructor(t,e,i,n,r,s,a,o,l){super(t,e,i,n,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Eo extends Ri{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ni(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 Ni(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Ht(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.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class _o extends Eo{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ht(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Dt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ni(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ni(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ni(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}function yo(t,e,i){return!t||!i&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)}function xo(t){const e=t.length,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i}function So(t,e,i){const n=t.length,r=new t.constructor(n);for(let s=0,a=0;a!==n;++s){const n=i[s]*e;for(let i=0;i!==e;++i)r[a++]=t[n+i]}return r}function Co(t,e,i,n){let r=1,s=t[0];for(;void 0!==s&&void 0===s[n];)s=t[r++];if(void 0===s)return;let a=s[n];if(void 0!==a)if(Array.isArray(a))do{a=s[n],void 0!==a&&(e.push(s.time),i.push.apply(i,a)),s=t[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[n],void 0!==a&&(e.push(s.time),a.toArray(i,i.length)),s=t[r++]}while(void 0!==s);else do{a=s[n],void 0!==a&&(e.push(s.time),i.push(a)),s=t[r++]}while(void 0!==s)}class Io{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],r=e[i-1];t:{e:{let s;i:{n:if(!(t=r)break t;{const a=e[1];t=r)break e}s=i,i=0}}for(;i>>1;te;)--s;if(++s,0!==r||s!==n){r>=s&&(s=Math.max(s,1),r=s-1);const t=this.getValueSize();this.times=i.slice(r,s),this.values=this.values.slice(r*t,s*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let s=null;for(let e=0;e!==r;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==s&&s>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,s),t=!1;break}s=n}if(void 0!==n&&(a=n,ArrayBuffer.isView(a)&&!(a instanceof DataView)))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}var a;return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===at,r=t.length-1;let s=1;for(let a=1;a0){t[s]=t[r];for(let t=r*i,n=s*i,a=0;a!==i;++a)e[n+a]=e[t+a];++s}return s!==t.length?(this.times=t.slice(0,s),this.values=e.slice(0,s*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=new(0,this.constructor)(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}To.prototype.TimeBufferType=Float32Array,To.prototype.ValueBufferType=Float32Array,To.prototype.DefaultInterpolation=st;class Bo extends To{}Bo.prototype.ValueTypeName="bool",Bo.prototype.ValueBufferType=Array,Bo.prototype.DefaultInterpolation=rt,Bo.prototype.InterpolantFactoryMethodLinear=void 0,Bo.prototype.InterpolantFactoryMethodSmooth=void 0;class Ro extends To{}Ro.prototype.ValueTypeName="color";class Lo extends To{}Lo.prototype.ValueTypeName="number";class Do extends Io{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(i-e)/(n-e);let l=t*a;for(let t=l+a;l!==t;l+=4)me.slerpFlat(r,0,s,l-a,s,l,o);return r}}class Uo extends To{InterpolantFactoryMethodLinear(t){return new Do(this.times,this.values,this.getValueSize(),t)}}Uo.prototype.ValueTypeName="quaternion",Uo.prototype.DefaultInterpolation=st,Uo.prototype.InterpolantFactoryMethodSmooth=void 0;class Po extends To{}Po.prototype.ValueTypeName="string",Po.prototype.ValueBufferType=Array,Po.prototype.DefaultInterpolation=rt,Po.prototype.InterpolantFactoryMethodLinear=void 0,Po.prototype.InterpolantFactoryMethodSmooth=void 0;class No extends To{}No.prototype.ValueTypeName="vector";class Qo{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Lt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(Fo(i[t]).scale(n));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=i.length;t!==n;++t)e.push(To.toJSON(i[t]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const r=e.length,s=[];for(let t=0;t1){const t=s[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const s=[];for(const t in n)s.push(this.CreateFromMorphTargetSequence(t,n[t],e,i));return s}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,r){if(0!==i.length){const s=[],a=[];Co(i,s,a,n),0!==s.length&&r.push(new t(e,s,a))}},n=[],r=t.name||"default",s=t.fps||30,a=t.blendMode;let o=t.length||-1;const l=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)}),0),r;if(void 0!==zo[t])return void zo[t].push({onLoad:e,onProgress:i,onError:n});zo[t]=[],zo[t].push({onLoad:e,onProgress:i,onError:n});const s=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body||void 0===e.body.getReader)return e;const i=zo[t],n=e.body.getReader(),r=e.headers.get("Content-Length")||e.headers.get("X-File-Size"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(t){!function e(){n.read().then((({done:n,value:r})=>{if(n)t.close();else{o+=r.byteLength;const n=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let t=0,e=i.length;t{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((t=>(new DOMParser).parseFromString(t,a)));case"json":return t.json();default:if(void 0===a)return t.text();{const e=/charset="?([^;"\s]*)"?/i.exec(a),i=e&&e[1]?e[1].toLowerCase():void 0,n=new TextDecoder(i);return t.arrayBuffer().then((t=>n.decode(t)))}}})).then((e=>{Oo.add(t,e);const i=zo[t];delete zo[t];for(let t=0,n=i.length;t{const i=zo[t];if(void 0===i)throw this.manager.itemError(t),e;delete zo[t];for(let t=0,n=i.length;t{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class qo extends Ho{constructor(t){super(t)}load(t,e,i,n){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,s=Oo.get(t);if(void 0!==s)return r.manager.itemStart(t),setTimeout((function(){e&&e(s),r.manager.itemEnd(t)}),0),s;const a=qt("img");function o(){c(),Oo.add(t,this),e&&e(this),r.manager.itemEnd(t)}function l(e){c(),n&&n(e),r.manager.itemError(t),r.manager.itemEnd(t)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(t),a.src=t,a}}class Xo extends Ho{constructor(t){super(t)}load(t,e,i,n){const r=this,s=new Na,a=new Wo(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,(function(t){let i;try{i=r.parse(t)}catch(t){if(void 0===n)return void console.error(t);n(t)}void 0!==i.image?s.image=i.image:void 0!==i.data&&(s.image.width=i.width,s.image.height=i.height,s.image.data=i.data),s.wrapS=void 0!==i.wrapS?i.wrapS:I,s.wrapT=void 0!==i.wrapT?i.wrapT:I,s.magFilter=void 0!==i.magFilter?i.magFilter:B,s.minFilter=void 0!==i.minFilter?i.minFilter:B,s.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace?s.colorSpace=i.colorSpace:void 0!==i.encoding&&(s.encoding=i.encoding),void 0!==i.flipY&&(s.flipY=i.flipY),void 0!==i.format&&(s.format=i.format),void 0!==i.type&&(s.type=i.type),void 0!==i.mipmaps&&(s.mipmaps=i.mipmaps,s.minFilter=L),1===i.mipmapCount&&(s.minFilter=B),void 0!==i.generateMipmaps&&(s.generateMipmaps=i.generateMipmaps),s.needsUpdate=!0,e&&e(s,i)}),i,n),s}}class jo extends Ho{constructor(t){super(t)}load(t,e,i,n){const r=new ce,s=new qo(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(t,(function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r}}class Yo extends fi{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ni(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}const Ko=new qe,Jo=new ge,$o=new ge;class Zo{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ht(512,512),this.map=null,this.mapPass=null,this.matrix=new qe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new kn,this._frameExtents=new Ht(1,1),this._viewportCount=1,this._viewports=[new he(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Jo.setFromMatrixPosition(t.matrixWorld),e.position.copy(Jo),$o.setFromMatrixPosition(t.target.matrixWorld),e.lookAt($o),e.updateMatrixWorld(),Ko.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ko),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Ko)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class tl extends Zo{constructor(){super(new Tn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=2*Rt*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;i===e.fov&&n===e.aspect&&r===e.far||(e.fov=i,e.aspect=n,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class el extends Yo{constructor(t,e,i=0,n=Math.PI/3,r=0,s=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(fi.DEFAULT_UP),this.updateMatrix(),this.target=new fi,this.distance=i,this.angle=n,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new tl}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const il=new qe,nl=new ge,rl=new ge;class sl extends Zo{constructor(){super(new Tn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ht(4,2),this._viewportCount=6,this._viewports=[new he(2,1,1,1),new he(0,1,1,1),new he(3,1,1,1),new he(1,1,1,1),new he(3,0,1,1),new he(1,0,1,1)],this._cubeDirections=[new ge(1,0,0),new ge(-1,0,0),new ge(0,0,1),new ge(0,0,-1),new ge(0,1,0),new ge(0,-1,0)],this._cubeUps=[new ge(0,1,0),new ge(0,1,0),new ge(0,1,0),new ge(0,1,0),new ge(0,0,1),new ge(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,n=this.matrix,r=t.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),nl.setFromMatrixPosition(t.matrixWorld),i.position.copy(nl),rl.copy(i.position),rl.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(rl),i.updateMatrixWorld(),n.makeTranslation(-nl.x,-nl.y,-nl.z),il.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(il)}}class al extends Yo{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new sl}get power(){return 4*this.intensity*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class ol extends Zo{constructor(){super(new tr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ll extends Yo{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(fi.DEFAULT_UP),this.updateMatrix(),this.target=new fi,this.shadow=new ol}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class cl{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new ge)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.282095),e.addScaledVector(s[1],.488603*n),e.addScaledVector(s[2],.488603*r),e.addScaledVector(s[3],.488603*i),e.addScaledVector(s[4],i*n*1.092548),e.addScaledVector(s[5],n*r*1.092548),e.addScaledVector(s[6],.315392*(3*r*r-1)),e.addScaledVector(s[7],i*r*1.092548),e.addScaledVector(s[8],.546274*(i*i-n*n)),e}getIrradianceAt(t,e){const i=t.x,n=t.y,r=t.z,s=this.coefficients;return e.copy(s[0]).multiplyScalar(.886227),e.addScaledVector(s[1],1.023328*n),e.addScaledVector(s[2],1.023328*r),e.addScaledVector(s[3],1.023328*i),e.addScaledVector(s[4],.858086*i*n),e.addScaledVector(s[5],.858086*n*r),e.addScaledVector(s[6],.743125*r*r-.247708),e.addScaledVector(s[7],.858086*i*r),e.addScaledVector(s[8],.429043*(i*i-n*n)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(t.coefficients[i],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let i=0;i<9;i++)this.coefficients[i].lerp(t.coefficients[i],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(t,e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(t,e+3*n);return this}toArray(t=[],e=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(t,e+3*n);return t}static getBasisAt(t,e){const i=t.x,n=t.y,r=t.z;e[0]=.282095,e[1]=.488603*n,e[2]=.488603*r,e[3]=.488603*i,e[4]=1.092548*i*n,e[5]=1.092548*n*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*i*r,e[8]=.546274*(i*i-n*n)}}class hl extends Yo{constructor(t=new cl,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){const e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}}class ul{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let i=0,n=t.length;i0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){a.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let t=i,r=n;t!==r;++t)e[t]=e[n+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let n=0;n!==r;++n)t[e+n]=t[i+n]}_slerp(t,e,i,n){me.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,r){const s=this._workIndex*r;me.multiplyQuaternionsFlat(t,s,t,e,t,i),me.slerpFlat(t,e,t,e,t,s,n)}_lerp(t,e,i,n,r){const s=1-n;for(let a=0;a!==r;++a){const r=e+a;t[r]=t[r]*s+t[i+a]*n}}_lerpAdditive(t,e,i,n,r){for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]+t[i+s]*n}}}const pl="\\[\\]\\.:\\/",ml=new RegExp("["+pl+"]","g"),gl="[^"+pl+"]",fl="[^"+pl.replace("\\.","")+"]",vl=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",gl)+/(WCOD+)?/.source.replace("WCOD",fl)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gl)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gl)+"$"),El=["material","materials","bones","map"];class _l{constructor(t,e,i){this.path=e,this.parsedPath=i||_l.parseTrackName(e),this.node=_l.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new _l.Composite(t,e,i):new _l(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ml,"")}static parseTrackName(t){const e=vl.exec(t);if(null===e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==El.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n0){const t=this._interpolants,e=this._propertyBindings;if(2501===this.blendMode)for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(s),e[i].accumulateAdditive(a);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(s),e[i].accumulate(n,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,r=this._loopCount;const s=i===nt;if(0===t)return-1===r?n:s&&1==(1&r)?e-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,r+=Math.abs(i);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){const e=t<0;this._setEndings(e,!e,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(s&&1==(1&r))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=lt,n.endingEnd=lt):(n.endingStart=t?this.zeroSlopeAtStart?lt:ot:ct,n.endingEnd=e?this.zeroSlopeAtEnd?lt:ot:ct)}_scheduleFading(t,e,i){const n=this._mixer,r=n.time;let s=this._weightInterpolant;null===s&&(s=n._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=i,this}}const xl=new Float32Array(1);class Sl extends Mt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,s=t._propertyBindings,a=t._interpolants,o=i.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let t=0;t!==r;++t){const r=n[t],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[t]=h;else{if(h=s[t],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;h=new Al(_l.create(i,l,n),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[t]=h}a[t].resultBuffer=h.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),s=this._accuIndex^=1;for(let a=0;a!==i;++a){e[a]._update(n,t,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(s);return this}setTime(t){this.time=0;for(let t=0;tt:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new Ll("string"==typeof t?t:t+"",void 0,Bl))(e)})(t):t +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */;var Ul;const Pl=window,Nl=Pl.trustedTypes,Ql=Nl?Nl.emptyScript:"",Fl=Pl.reactiveElementPolyfillSupport,Ol={toAttribute(t,e){switch(e){case Boolean:t=t?Ql:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},kl=(t,e)=>e!==t&&(e==e||t==t),Gl={attribute:!0,type:String,converter:Ol,reflect:!1,hasChanged:kl},Hl="finalized";class zl extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const n=this._$Ep(i,e);void 0!==n&&(this._$Ev.set(n,i),t.push(n))})),t}static createProperty(t,e=Gl){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const r=this[t];this[e]=n,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Gl}static finalize(){if(this.hasOwnProperty(Hl))return!1;this[Hl]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(Dl(t))}else void 0!==t&&e.push(Dl(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{Tl?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),n=bl.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=Gl){var n;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:Ol).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const n=this.constructor,r=n._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=n.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:Ol;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let n=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||kl)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}} +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */ +var Vl;zl[Hl]=!0,zl.elementProperties=new Map,zl.elementStyles=[],zl.shadowRootOptions={mode:"open"},null==Fl||Fl({ReactiveElement:zl}),(null!==(Ul=Pl.reactiveElementVersions)&&void 0!==Ul?Ul:Pl.reactiveElementVersions=[]).push("1.6.3");const Wl=window,ql=Wl.trustedTypes,Xl=ql?ql.createPolicy("lit-html",{createHTML:t=>t}):void 0,jl="$lit$",Yl=`lit$${(Math.random()+"").slice(9)}$`,Kl="?"+Yl,Jl=`<${Kl}>`,$l=document,Zl=()=>$l.createComment(""),tc=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ec=Array.isArray,ic="[ \t\n\f\r]",nc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,rc=/-->/g,sc=/>/g,ac=RegExp(`>|${ic}(?:([^\\s"'>=/]+)(${ic}*=${ic}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),oc=/'/g,lc=/"/g,cc=/^(?:script|style|textarea|title)$/i,hc=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),uc=Symbol.for("lit-noChange"),dc=Symbol.for("lit-nothing"),Ac=new WeakMap,pc=$l.createTreeWalker($l,129,null,!1);function mc(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Xl?Xl.createHTML(e):e}const gc=(t,e)=>{const i=t.length-1,n=[];let r,s=2===e?"":"",a=nc;for(let e=0;e"===l[0]?(a=null!=r?r:nc,c=-1):void 0===l[1]?c=-2:(c=a.lastIndex-l[2].length,o=l[1],a=void 0===l[3]?ac:'"'===l[3]?lc:oc):a===lc||a===oc?a=ac:a===rc||a===sc?a=nc:(a=ac,r=void 0);const u=a===ac&&t[e+1].startsWith("/>")?" ":"";s+=a===nc?i+Jl:c>=0?(n.push(o),i.slice(0,c)+jl+i.slice(c)+Yl+u):i+Yl+(-2===c?(n.push(void 0),e):u)}return[mc(t,s+(t[i]||"")+(2===e?"":"")),n]};class fc{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,s=0;const a=t.length-1,o=this.parts,[l,c]=gc(t,e);if(this.el=fc.createElement(l,i),pc.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(n=pc.nextNode())&&o.length0){n.textContent=ql?ql.emptyScript:"";for(let i=0;iec(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==dc&&tc(this._$AH)?this._$AA.nextSibling.data=t:this.$($l.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=fc.createElement(mc(n.h,n.h[0]),this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(i);else{const t=new Ec(r,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=Ac.get(t.strings);return void 0===e&&Ac.set(t.strings,e=new fc(t)),e}T(t){ec(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const r of t)n===e.length?e.push(i=new _c(this.k(Zl()),this.k(Zl()),this,this.options)):i=e[n],i._$AI(r),n++;n2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=dc}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,n){const r=this.strings;let s=!1;if(void 0===r)t=vc(this,t,e,0),s=!tc(t)||t!==this._$AH&&t!==uc,s&&(this._$AH=t);else{const n=t;let a,o;for(t=r[0],a=0;a{var n,r;const s=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:e;let a=s._$litPart$;if(void 0===a){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=a=new _c(e.insertBefore(Zl(),t),t,void 0,null!=i?i:{})}return a._$AI(t),a +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */},Tc=window,Bc=Tc.ShadowRoot&&(void 0===Tc.ShadyCSS||Tc.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Rc=Symbol(),Lc=new WeakMap;class Dc{constructor(t,e,i){if(this._$cssResult$=!0,i!==Rc)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Bc&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=Lc.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Lc.set(e,t))}return t}toString(){return this.cssText}}const Uc=Bc?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new Dc("string"==typeof t?t:t+"",void 0,Rc))(e)})(t):t +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */;var Pc;const Nc=window,Qc=Nc.trustedTypes,Fc=Qc?Qc.emptyScript:"",Oc=Nc.reactiveElementPolyfillSupport,kc={toAttribute(t,e){switch(e){case Boolean:t=t?Fc:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},Gc=(t,e)=>e!==t&&(e==e||t==t),Hc={attribute:!0,type:String,converter:kc,reflect:!1,hasChanged:Gc},zc="finalized";class Vc extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const n=this._$Ep(i,e);void 0!==n&&(this._$Ev.set(n,i),t.push(n))})),t}static createProperty(t,e=Hc){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const r=this[t];this[e]=n,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||Hc}static finalize(){if(this.hasOwnProperty(zc))return!1;this[zc]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(Uc(t))}else void 0!==t&&e.push(Uc(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{Bc?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),n=Tc.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=Hc){var n;const r=this.constructor._$Ep(t,i);if(void 0!==r&&!0===i.reflect){const s=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:kc).toAttribute(e,i.type);this._$El=t,null==s?this.removeAttribute(r):this.setAttribute(r,s),this._$El=null}}_$AK(t,e){var i;const n=this.constructor,r=n._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=n.getPropertyOptions(r),s="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:kc;this._$El=r,this[r]=s.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let n=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||Gc)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}} +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */ +var Wc,qc;Vc[zc]=!0,Vc.elementProperties=new Map,Vc.elementStyles=[],Vc.shadowRootOptions={mode:"open"},null==Oc||Oc({ReactiveElement:Vc}),(null!==(Pc=Nc.reactiveElementVersions)&&void 0!==Pc?Pc:Nc.reactiveElementVersions=[]).push("1.6.3");class Xc extends Vc{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=bc(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return uc}}Xc.finalized=!0,Xc._$litElement$=!0,null===(Wc=globalThis.litElementHydrateSupport)||void 0===Wc||Wc.call(globalThis,{LitElement:Xc});const jc=globalThis.litElementPolyfillSupport;null==jc||jc({LitElement:Xc}),(null!==(qc=globalThis.litElementVersions)&&void 0!==qc?qc:globalThis.litElementVersions=[]).push("3.3.3"); +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const Yc=null!=navigator.xr&&null!=self.XRSession&&null!=navigator.xr.isSessionSupported,Kc=Yc&&null!=self.XRSession.prototype.requestHitTestSource,Jc=null!=self.ResizeObserver,$c=null!=self.IntersectionObserver,Zc=Kc;(()=>{const t=navigator.userAgent||navigator.vendor||self.opera;let e=!1;(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)})(),/\bCrOS\b/.test(navigator.userAgent);const th=/android/i.test(navigator.userAgent),eh=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;/Safari\//.test(navigator.userAgent);const ih=/firefox/i.test(navigator.userAgent),nh=/OculusBrowser/.test(navigator.userAgent);eh&&/CriOS\//.test(navigator.userAgent);const rh=th&&!ih&&!nh,sh=Boolean(window.webkit&&window.webkit.messageHandlers),ah=(()=>{if(eh){if(sh)return Boolean(/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent));{const t=document.createElement("a");return Boolean(t.relList&&t.relList.supports&&t.relList.supports("ar"))}}return!1})(),oh=t=>t&&"null"!==t?ch(t):null,lh=()=>{if(Zc)return;const t=[];throw Yc||t.push("WebXR Device API"),Kc||t.push("WebXR Hit Test API"),new Error(`The following APIs are required for AR, but are missing in this browser: ${t.join(", ")}`)},ch=t=>new URL(t,window.location.toString()).toString(),hh=(t,e)=>{let i=null;return(...n)=>{null!=i&&self.clearTimeout(i),i=self.setTimeout((()=>{i=null,t(...n)}),e)}},uh=(t,e,i)=>Math.max(e,Math.min(i,t)),dh=(()=>{const t=(()=>{var t;if(null===(t=document.documentElement.getAttribute("itemtype"))||void 0===t?void 0:t.includes("schema.org/SearchResultsPage"))return!0;const e=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const t of e)if("viewport"===t.name)return!0;return!1})();return t||console.warn('No detected; will cap pixel density at 1.'),()=>t?window.devicePixelRatio:1})(),Ah=(()=>{const t=new RegExp("[?&]model-viewer-debug-mode(&|$)");return()=>self.ModelViewerElement&&self.ModelViewerElement.debugMode||self.location&&self.location.search&&self.location.search.match(t)})(); +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var ph=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const mh=Symbol("currentEnvironmentMap"),gh=Symbol("currentBackground"),fh=Symbol("updateEnvironment"),vh=Symbol("cancelEnvironmentUpdate"); +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const Eh=hc` + +
+ + + +
+ + + +
+ + + +
+ +
+
+
+
+ +
+
+ +
+
+ +
+ +
+
+ +
+ + +
+
+ +
`,_h=new WeakMap;function yh(){let t,e;function i(t,e,i,n,r,s){const a=s.num_components(),o=i.num_points()*a,l=o*r.BYTES_PER_ELEMENT,c=function(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32}}(t,r),h=t._malloc(l);e.GetAttributeDataArrayForAllPoints(i,s,c,l,h);const u=new r(t.HEAPF32.buffer,h,o).slice();return t._free(h),{name:n,array:u,itemSize:a}}onmessage=function(n){const r=n.data;switch(r.type){case"init":t=r.decoderConfig,e=new Promise((function(e){t.onModuleLoaded=function(t){e({draco:t})},DracoDecoderModule(t)}));break;case"decode":const n=r.buffer,s=r.taskConfig;e.then((t=>{const e=t.draco,a=new e.Decoder;try{const t=function(t,e,n,r){const s=r.attributeIDs,a=r.attributeTypes;let o,l;const c=e.GetEncodedGeometryType(n);if(c===t.TRIANGULAR_MESH)o=new t.Mesh,l=e.DecodeArrayToMesh(n,n.byteLength,o);else{if(c!==t.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new t.PointCloud,l=e.DecodeArrayToPointCloud(n,n.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const n in s){const l=self[a[n]];let c,u;if(r.useUniqueIDs)u=s[n],c=e.GetAttributeByUniqueId(o,u);else{if(u=e.GetAttributeId(o,t[s[n]]),-1===u)continue;c=e.GetAttribute(o,u)}const d=i(t,e,o,n,l,c);"color"===n&&(d.vertexColorSpace=r.vertexColorSpace),h.attributes.push(d)}c===t.TRIANGULAR_MESH&&(h.index=function(t,e,i){const n=i.num_faces(),r=3*n,s=4*r,a=t._malloc(s);e.GetTrianglesUInt32Array(i,s,a);const o=new Uint32Array(t.HEAPF32.buffer,a,r).slice();return t._free(a),{array:o,itemSize:1}}(t,e,o));return t.destroy(o),h}(e,a,new Int8Array(n),s),o=t.attributes.map((t=>t.array.buffer));t.index&&o.push(t.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:t},o)}catch(t){console.error(t),self.postMessage({type:"error",id:r.id,error:t.message})}finally{e.destroy(a)}}))}}}function xh(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let i=t.getIndex();if(null===i){const e=[],n=t.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t=2.0 are supported.")));const l=new fu(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===a[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(i,n)}parseAsync(t,e){const i=this;return new Promise((function(n,r){i.parse(t,e,n,r)}))}}function Ch(){let t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const Ih={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class wh{constructor(t){this.parser=t,this.name=Ih.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Fh{constructor(t){this.parser=t,this.name=Ih.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class Oh{constructor(t){this.parser=t,this.name=Ih.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const t=i.options.manager.getHandler(a.uri);null!==t&&(o=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(1===e.height)}}))),this.isSupported}}class kh{constructor(t){this.name=Ih.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const t=i.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(e){const i=t.byteOffset||0,n=t.byteLength||0,s=t.count,a=t.byteStride,o=new Uint8Array(e,i,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,t.mode,t.filter).then((function(t){return t.buffer})):r.ready.then((function(){const e=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(e),s,a,o,t.mode,t.filter),e}))}))}return null}}class Gh{constructor(t){this.name=Ih.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=e.meshes[i.mesh];for(const t of n.primitives)if(t.mode!==$h.TRIANGLES&&t.mode!==$h.TRIANGLE_STRIP&&t.mode!==$h.TRIANGLE_FAN&&void 0!==t.mode)return null;const r=i.extensions[this.name].attributes,s=[],a={};for(const t in r)s.push(this.parser.getDependency("accessor",r[t]).then((e=>(a[t]=e,a[t]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const e=t.pop(),i=e.isGroup?e.children:[e],n=t[0].count,r=[];for(const t of i){const e=new qe,i=new ge,s=new me,o=new ge(1,1,1),l=new ja(t.geometry,t.material,n);for(let t=0;t-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||i||n&&r<98?this.textureLoader=new jo(this.options.manager):this.textureLoader=new dl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Wo(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(t){return t._markDefs&&t._markDefs()})),Promise.all(this._invokeAll((function(t){return t.beforeRoot&&t.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(e){const s={scene:e[0][n.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:n.asset,parser:i,userData:{}};return hu(r,s,n),uu(s,n),Promise.all(i._invokeAll((function(t){return t.afterRoot&&t.afterRoot(s)}))).then((function(){t(s)}))})).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=e.length;i{const i=this.associations.get(t);null!=i&&this.associations.set(e,i);for(const[i,n]of t.children.entries())r(n,e.children[i])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i=2&&A.setY(e,h[t*s+1]),s>=3&&A.setZ(e,h[t*s+2]),s>=4&&A.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return A}))}loadTexture(t){const e=this.json,i=this.options,n=e.textures[t].source,r=e.images[n];let s=this.textureLoader;if(r.uri){const t=i.manager.getHandler(r.uri);null!==t&&(s=t)}return this.loadTextureImage(t,n,s)}loadTextureImage(t,e,i){const n=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(e,i).then((function(e){e.flipY=!1,e.name=s.name||a.name||"",""===e.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(e.name=a.uri);const i=(r.samplers||{})[s.sampler]||{};return e.magFilter=tu[i.magFilter]||B,e.minFilter=tu[i.minFilter]||L,e.wrapS=eu[i.wrapS]||C,e.wrapT=eu[i.wrapT]||C,n.associations.set(e,{textures:t}),e})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((t=>t.clone()));const s=n.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=i.getDependency("bufferView",s.bufferView).then((function(t){l=!0;const e=new Blob([t],{type:s.mimeType});return o=a.createObjectURL(e),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(t){return new Promise((function(i,n){let s=i;!0===e.isImageBitmapLoader&&(s=function(t){const e=new ce(t);e.needsUpdate=!0,i(e)}),e.load(ul.resolveURL(t,r.path),s,void 0,n)}))})).then((function(t){var e;return!0===l&&a.revokeObjectURL(o),t.userData.mimeType=s.mimeType||((e=s.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"),t})).catch((function(t){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),t}));return this.sourceCache[t]=c,c}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then((function(s){if(!s)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((s=s.clone()).channel=i.texCoord),r.extensions[Ih.KHR_TEXTURE_TRANSFORM]){const t=void 0!==i.extensions?i.extensions[Ih.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(s);s=r.extensions[Ih.KHR_TEXTURE_TRANSFORM].extendTexture(s,t),r.associations.set(s,e)}}return void 0!==n&&(s.colorSpace=n),t[e]=s,s}))}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=void 0===e.attributes.tangent,r=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new ao,Ri.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,e.sizeAttenuation=!1,this.cache.add(t,e)),i=e}else if(t.isLine){const t="LineBasicMaterial:"+i.uuid;let e=this.cache.get(t);e||(e=new Ya,Ri.prototype.copy.call(e,i),e.color.copy(i.color),e.map=i.map,this.cache.add(t,e)),i=e}if(n||r||s){let t="ClonedMaterial:"+i.uuid+":";n&&(t+="derivative-tangents:"),r&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=i.clone(),r&&(e.vertexColors=!0),s&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(i))),i=e}t.material=i}getMaterialType(){return Eo}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let s;const a={},o=[];if((r.extensions||{})[Ih.KHR_MATERIALS_UNLIT]){const t=n[Ih.KHR_MATERIALS_UNLIT];s=t.getMaterialType(),o.push(t.extendParams(a,r,e))}else{const i=r.pbrMetallicRoughness||{};if(a.color=new Ni(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],pt),a.opacity=t[3]}void 0!==i.baseColorTexture&&o.push(e.assignTexture(a,"map",i.baseColorTexture,At)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(e.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),o.push(e.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),o.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===r.doubleSided&&(a.side=c);const l=r.alphaMode||au;if(l===lu?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===ou&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==Fi&&(o.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ht(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;a.normalScale.set(t,t)}if(void 0!==r.occlusionTexture&&s!==Fi&&(o.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==Fi){const t=r.emissiveFactor;a.emissive=(new Ni).setRGB(t[0],t[1],t[2],pt)}return void 0!==r.emissiveTexture&&s!==Fi&&o.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,At)),Promise.all(o).then((function(){const i=new s(a);return r.name&&(i.name=r.name),uu(i,r),e.associations.set(i,{materials:t}),r.extensions&&hu(n,i,r),i}))}createUniqueName(t){const e=_l.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(t){return i[Ih.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(i){return vu(i,t,e)}))}const s=[];for(let i=0,a=t.length;i0&&du(u,r),u.name=e.createUniqueName(r.name||"mesh_"+t),uu(u,r),h.extensions&&hu(n,u,h),e.assignFinalMaterial(u),l.push(u)}for(let i=0,n=l.length;i1?new Aa:1===e.length?e[0]:new fi,a!==e[0])for(let t=0,i=e.length;t{const e=new Map;for(const[t,i]of n.associations)(t instanceof Ri||t instanceof ce)&&e.set(t,i);return t.traverse((t=>{const i=n.associations.get(t);null!=i&&e.set(t,i)})),e})(r),r}))}_createAnimationTracks(t,e,i,n,r){const s=[],a=t.name?t.name:t.uuid,o=[];let l;switch(ru[r.path]===ru.weights?t.traverse((function(t){t.morphTargetInfluences&&o.push(t.name?t.name:t.uuid)})):o.push(a),ru[r.path]){case ru.weights:l=Lo;break;case ru.rotation:l=Uo;break;case ru.position:case ru.scale:l=No;break;default:if(1===i.itemSize)l=Lo;else l=No}const c=void 0!==n.interpolation?su[n.interpolation]:st,h=this._getArrayFromAccessor(i);for(let t=0,i=o.length;t{const n=this._getIdleWorker();-1!==n?(this._initWorker(n),this.workerStatus|=1<t.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const _u=2,yu=0,xu=1,Su=10;class Cu{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Iu{constructor(t,e,i,n){this._dataView=new DataView(t.buffer,t.byteOffset+e,i),this._littleEndian=n,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_skip(t){return this._offset+=t,this}_scan(t,e=0){const i=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==e&&nt.arrayBuffer())).then((t=>WebAssembly.instantiate(t,Ru))).then(this._init):WebAssembly.instantiate(Buffer.from(Du,"base64"),Ru).then(this._init),bu)}_init(t){Tu=t.instance,Ru.env.emscripten_notify_memory_growth(0)}decode(t,e=0){if(!Tu)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=t.byteLength,n=Tu.exports.malloc(i);Bu.set(t,n),e=e||Number(Tu.exports.ZSTD_findDecompressedSize(n,i));const r=Tu.exports.malloc(e),s=Tu.exports.ZSTD_decompress(r,e,n,i),a=Bu.slice(r,r+s);return Tu.exports.free(n),Tu.exports.free(r),a}}const Du="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IAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigC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C0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdB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IAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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",Uu=new WeakMap;let Pu,Nu=0;class Qu extends Ho{constructor(t){super(t),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new Eu,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(t){return this.transcoderPath=t,this}setWorkerLimit(t){return this.workerPool.setWorkerLimit(t),this}detectSupport(t){return!0===t.isWebGPURenderer?this.workerConfig={astcSupported:t.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:t.hasFeature("texture-compression-etc2"),dxtSupported:t.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:t.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:t.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:t.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:t.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:t.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:t.extensions.has("WEBGL_compressed_texture_pvrtc")||t.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},t.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const t=new Wo(this.manager);t.setPath(this.transcoderPath),t.setWithCredentials(this.withCredentials);const e=t.loadAsync("basis_transcoder.js"),i=new Wo(this.manager);i.setPath(this.transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const n=i.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([e,n]).then((([t,e])=>{const i=Qu.BasisWorker.toString(),n=["/* constants */","let _EngineFormat = "+JSON.stringify(Qu.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(Qu.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Qu.BasisFormat),"/* basis_transcoder.js */",t,"/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n])),this.transcoderBinary=e,this.workerPool.setWorkerCreator((()=>{const t=new Worker(this.workerSourceURL),e=this.transcoderBinary.slice(0);return t.postMessage({type:"init",config:this.workerConfig,transcoderBinary:e},[e]),t}))})),Nu>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),Nu++}return this.transcoderPending}load(t,e,i,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new Wo(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(t,(t=>{if(Uu.has(t)){return Uu.get(t).promise.then(e).catch(n)}this._createTexture(t).then((t=>e?e(t):null)).catch(n)}),i,n)}_createTextureFrom(t,e){const{faces:i,width:n,height:r,format:s,type:a,error:o,dfdFlags:l}=t;if("error"===a)return Promise.reject(o);let c;if(6===e.faceCount)c=new fo(i,s,D);else{const t=i[0].mipmaps;c=e.layerCount>1?new go(t,n,r,e.layerCount,s,D):new mo(t,n,r,s,D)}return c.minFilter=1===i[0].mipmaps.length?B:L,c.magFilter=B,c.generateMipmaps=!1,c.needsUpdate=!0,c.colorSpace=Gu(e),c.premultiplyAlpha=!!(1&l),c}async _createTexture(t,e={}){const i=function(t){const e=new Uint8Array(t.buffer,t.byteOffset,wu.length);if(e[0]!==wu[0]||e[1]!==wu[1]||e[2]!==wu[2]||e[3]!==wu[3]||e[4]!==wu[4]||e[5]!==wu[5]||e[6]!==wu[6]||e[7]!==wu[7]||e[8]!==wu[8]||e[9]!==wu[9]||e[10]!==wu[10]||e[11]!==wu[11])throw new Error("Missing KTX 2.0 identifier.");const i=new Cu,n=17*Uint32Array.BYTES_PER_ELEMENT,r=new Iu(t,wu.length,n,!0);i.vkFormat=r._nextUint32(),i.typeSize=r._nextUint32(),i.pixelWidth=r._nextUint32(),i.pixelHeight=r._nextUint32(),i.pixelDepth=r._nextUint32(),i.layerCount=r._nextUint32(),i.faceCount=r._nextUint32();const s=r._nextUint32();i.supercompressionScheme=r._nextUint32();const a=r._nextUint32(),o=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),h=r._nextUint64(),u=r._nextUint64(),d=new Iu(t,wu.length+n,3*s*8,!0);for(let e=0;e{const e=new Lu;await e.init(),t(e)}))),i=await Pu);const n=[];for(let r=0;r>r),a=Math.max(1,t.pixelHeight>>r),o=t.pixelDepth?Math.max(1,t.pixelDepth>>r):0,l=t.levels[r];let c,h;if(0===t.supercompressionScheme)c=l.levelData;else{if(2!==t.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");c=i.decode(l.levelData,l.uncompressedByteLength)}h=ku[e]===Q?new Float32Array(c.buffer,c.byteOffset,c.byteLength/Float32Array.BYTES_PER_ELEMENT):ku[e]===F?new Uint16Array(c.buffer,c.byteOffset,c.byteLength/Uint16Array.BYTES_PER_ELEMENT):c,n.push({data:h,width:s,height:a,depth:o})}let r;if(Fu.has(Ou[e]))r=0===t.pixelDepth?new Na(n[0].data,t.pixelWidth,t.pixelHeight):new pe(n[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth);else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new mo(n,t.pixelWidth,t.pixelHeight)}return r.mipmaps=n,r.type=ku[e],r.format=Ou[e],r.colorSpace=Gu(t),r.needsUpdate=!0,Promise.resolve(r)}(i);const n=e,r=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:t,taskConfig:n},[t]))).then((t=>this._createTextureFrom(t.data,i)));return Uu.set(t,{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Nu--,this}}Qu.BasisFormat={ETC1S:0,UASTC_4x4:1},Qu.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},Qu.EngineFormat={RGBAFormat:k,RGBA_ASTC_4x4_Format:Z,RGBA_BPTC_Format:et,RGBA_ETC2_EAC_Format:$,RGBA_PVRTC_4BPPV1_Format:K,RGBA_S3TC_DXT5_Format:j,RGB_ETC1_Format:36196,RGB_ETC2_Format:J,RGB_PVRTC_4BPPV1_Format:Y,RGB_S3TC_DXT1_Format:W},Qu.BasisWorker=function(){let t,e,i;const n=_EngineFormat,r=_TranscoderFormat,s=_BasisFormat;self.addEventListener("message",(function(a){const u=a.data;switch(u.type){case"init":t=u.config,d=u.transcoderBinary,e=new Promise((t=>{i={wasmBinary:d,onRuntimeInitialized:t},BASIS(i)})).then((()=>{i.initializeBasis(),void 0===i.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":e.then((()=>{try{const{faces:e,buffers:a,width:d,height:A,hasAlpha:p,format:m,dfdFlags:g}=function(e){const a=new i.KTX2File(new Uint8Array(e));function u(){a.close(),a.delete()}if(!a.isValid())throw u(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const d=a.isUASTC()?s.UASTC_4x4:s.ETC1S,A=a.getWidth(),p=a.getHeight(),m=a.getLayers()||1,g=a.getLevels(),f=a.getFaces(),v=a.getHasAlpha(),E=a.getDFDFlags(),{transcoderFormat:_,engineFormat:y}=function(e,i,a,h){let u,d;const A=e===s.ETC1S?o:l;for(let n=0;n1?(r=o.origWidth,s=o.origHeight):(r=o.width,s=o.height);const l=new Uint8Array(a.getImageTranscodedSizeInBytes(i,e,0,_));if(!a.transcodeImage(l,i,e,t,_,0,-1,-1))throw u(),new Error("THREE.KTX2Loader: .transcodeImage failed.");n.push(l)}const o=h(n);e.push({data:o,width:r,height:s}),S.push(o.buffer)}x.push({mipmaps:e,width:A,height:p,format:y})}return u(),{faces:x,buffers:S,width:A,height:p,hasAlpha:v,format:y,dfdFlags:E}}(u.buffer);self.postMessage({type:"transcode",id:u.id,faces:e,width:d,height:A,hasAlpha:p,format:m,dfdFlags:g},a)}catch(t){console.error(t),self.postMessage({type:"error",id:u.id,error:t.message})}}))}var d}));const a=[{if:"astcSupported",basisFormat:[s.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGB_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[s.ETC1S,s.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],o=a.sort((function(t,e){return t.priorityETC1S-e.priorityETC1S})),l=a.sort((function(t,e){return t.priorityUASTC-e.priorityUASTC}));function c(t){return t<=2||0==(t&t-1)&&0!==t}function h(t){if(1===t.length)return t[0];let e=0;for(let i=0;i=this[Xu];--t){const e=this[Wu][t];0===this[Vu].get(e)&&(this[ju].delete(e),this[Wu].splice(t,1))}}} +/* @license + * Copyright 2021 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Ku=t=>{const e=new Map;for(const i of t.mappings)for(const t of i.variants)e.set(t,{material:null,gltfMaterialIndex:i.material});return e};class Ju{constructor(t){this.parser=t,this.name="KHR_materials_variants"}afterRoot(t){const e=this.parser,i=e.json;if(void 0===i.extensions||void 0===i.extensions[this.name])return null;const n=(t=>{const e=[],i=new Set;for(const n of t){let t=n,r=0;for(;i.has(t);)t=n+"."+ ++r;i.add(t),e.push(t)}return e})((i.extensions[this.name].variants||[]).map((t=>t.name)));for(const n of t.scenes)n.traverse((t=>{const n=t;if(!n.material)return;const r=e.associations.get(n);if(null==r||null==r.meshes||null==r.primitives)return;const s=i.meshes[r.meshes].primitives[r.primitives].extensions;s&&s[this.name]&&(n.userData.variantMaterials=Ku(s[this.name]))}));return t.userData.variants=n,Promise.resolve()}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var $u,Zu;ce.DEFAULT_ANISOTROPY=4;const td=new Map,ed=new Map;let id;const nd=new class extends Ho{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,i,n){const r=new Wo(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,(t=>{this.parse(t,e,n)}),i,n)}parse(t,e,i){this.decodeDracoFile(t,e,null,null,At).catch(i)}decodeDracoFile(t,e,i,n,r=pt){const s={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(t,s).then(e)}decodeGeometry(t,e){const i=JSON.stringify(e);if(_h.has(t)){const e=_h.get(t);if(e.key===i)return e.promise;if(0===t.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const r=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(r,s).then((i=>(n=i,new Promise(((i,s)=>{n._callbacks[r]={resolve:i,reject:s},n.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))))).then((t=>this._createGeometry(t.geometry)));return a.catch((()=>!0)).then((()=>{n&&r&&this._releaseTask(n,r)})),_h.set(t,{key:i,promise:a}),a}_createGeometry(t){const e=new en;t.index&&e.setIndex(new Vi(t.index.array,1));for(let i=0;i{i.load(t,e,void 0,n)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then((e=>{const i=e[0];t||(this.decoderConfig.wasmBinary=e[1]);const n=yh.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(t,e){return this._initDecoder().then((()=>{if(this.workerPool.lengthe._taskLoad?-1:1}));const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[t]=e,i._taskLoad+=e,i}))}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map((t=>t._taskLoad)))}dispose(){for(let t=0;tnew Ju(t))),this[hd]=t,this[ld].setDRACOLoader(nd),this[ld].setKTX2Loader(sd)}static setDRACODecoderLocation(t){id=t,nd.setDecoderPath(t)}static getDRACODecoderLocation(){return id}static setKTX2TranscoderLocation(t){rd=t,sd.setTranscoderPath(t)}static getKTX2TranscoderLocation(){return rd}static setMeshoptDecoderLocation(t){var e;ad!==t&&(ad=t,od=(e=t,new Promise(((t,i)=>{const n=document.createElement("script");document.body.appendChild(n),n.onload=t,n.onerror=i,n.async=!0,n.src=e}))).then((()=>MeshoptDecoder.ready)).then((()=>MeshoptDecoder)))}static getMeshoptDecoderLocation(){return ad}static initializeKTX2Loader(t){sd.detectSupport(t)}static get cache(){return td}static clearCache(){td.forEach(((t,e)=>{this.delete(e)})),this[cd].reset()}static has(t){return td.has(t)}static async delete(t){if(!this.has(t))return;const e=td.get(t);ed.delete(t),td.delete(t);(await e).dispose()}static hasFinishedLoading(t){return!!ed.get(t)}get[($u=cd,Zu=ld,cd)](){return this.constructor[cd]}async preload(t,e,i=(()=>{})){if(this[ld].setWithCredentials(ud.withCredentials),this.dispatchEvent({type:"preload",element:e,src:t}),!td.has(t)){null!=od&&this[ld].setMeshoptDecoder(await od);const e=((t,e,i=(()=>{}))=>{const n=t=>{const e=t.loaded/t.total;i(Math.max(0,Math.min(1,isFinite(e)?e:1)))};return new Promise(((i,r)=>{e.load(t,i,n,r)}))})(t,this[ld],(t=>{i(.8*t)})),n=this[hd],r=e.then((t=>n.prepare(t))).then((t=>(i(.9),new n(t)))).catch((t=>(console.error(t),new n)));td.set(t,r)}await td.get(t),ed.set(t,!0),i&&i(1)}async load(t,e,i=(()=>{})){await this.preload(t,e,i);const n=await td.get(t),r=await n.clone();return this[cd].retain(t),r.dispose=()=>{this[cd].release(t)},r}}ud[$u]=new Yu(ud);class dd extends fi{constructor(t=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=t,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new Ht(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(t){t.element instanceof Element&&null!==t.element.parentNode&&t.element.parentNode.removeChild(t.element)}))}))}copy(t,e){return super.copy(t,e),this.element=t.element.cloneNode(!0),this.center=t.center,this}}const Ad=new ge,pd=new qe,md=new qe,gd=new ge,fd=new ge;class vd{constructor(t={}){const e=this;let i,n,r,s;const a={objects:new WeakMap},o=void 0!==t.element?t.element:document.createElement("div");function l(t,i,n){if(t.isCSS2DObject){Ad.setFromMatrixPosition(t.matrixWorld),Ad.applyMatrix4(md);const l=!0===t.visible&&Ad.z>=-1&&Ad.z<=1&&!0===t.layers.test(n.layers);if(t.element.style.display=!0===l?"":"none",!0===l){t.onBeforeRender(e,i,n);const a=t.element;a.style.transform="translate("+-100*t.center.x+"%,"+-100*t.center.y+"%)translate("+(Ad.x*r+r)+"px,"+(-Ad.y*s+s)+"px)",a.parentNode!==o&&o.appendChild(a),t.onAfterRender(e,i,n)}const h={distanceToCameraSquared:c(n,t)};a.objects.set(t,h)}for(let e=0,r=t.children.length;e{const{geometry:i}=t;if(void 0!==i){const{position:s}=i.attributes;if(void 0!==s)for(let i=0,a=s.count;it.toBlob(i,e)));let i;return"image/jpeg"===e?i=.92:"image/webp"===e&&(i=.8),t.convertToBlob({type:e,quality:i})}class sA{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(t){this.plugins=t}async write(t,e,i={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},i),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(t),await Promise.all(this.pending);const n=this,r=n.buffers,s=n.json;i=n.options;const a=n.extensionsUsed,o=n.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),c=Object.keys(a),h=Object.keys(o);if(c.length>0&&(s.extensionsUsed=c),h.length>0&&(s.extensionsRequired=h),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=l.size),!0===i.binary){const t=new FileReader;t.readAsArrayBuffer(l),t.onloadend=function(){const i=iA(t.result),n=new DataView(new ArrayBuffer(8));n.setUint32(0,i.byteLength,!0),n.setUint32(4,5130562,!0);const r=iA((a=JSON.stringify(s),(new TextEncoder).encode(a).buffer),32);var a;const o=new DataView(new ArrayBuffer(8));o.setUint32(0,r.byteLength,!0),o.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const h=12+o.byteLength+r.byteLength+n.byteLength+i.byteLength;c.setUint32(8,h,!0);const u=new Blob([l,o,r,n,i],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){e(d.result)}}}else if(s.buffers&&s.buffers.length>0){const t=new FileReader;t.readAsDataURL(l),t.onloadend=function(){const i=t.result;s.buffers[0].uri=i,e(s)}}else e(s)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const i=this.options,n=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(t.userData));if(i.includeCustomExtensions&&r.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in r.gltfExtensions)e.extensions[t]=r.gltfExtensions[t],n[t]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(e){console.warn("THREE.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+e.message)}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;const e=new ge;for(let i=0,n=t.count;i5e-4)return!1;return!0}createNormalizedNormalAttribute(t){const e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);const i=t.clone(),n=new ge;for(let t=0,e=i.count;t4?n=t.array[r*t.itemSize+i]:(0===i?n=t.getX(r):1===i?n=t.getY(r):2===i?n=t.getZ(r):3===i&&(n=t.getW(r)),!0===t.normalized&&(n=Gt.normalize(n,t.array))),e===Fd?l.setFloat32(c,n,!0):e===Nd?l.setInt32(c,n,!0):e===Qd?l.setUint32(c,n,!0):e===Ud?l.setInt16(c,n,!0):e===Pd?l.setUint16(c,n,!0):e===Ld?l.setInt8(c,n):e===Dd&&l.setUint8(c,n),c+=a}const h={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};void 0!==r&&(h.target=r),r===Od&&(h.byteStride=t.itemSize*a),this.byteOffset+=o,s.bufferViews.push(h);return{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,i=e.json;return i.bufferViews||(i.bufferViews=[]),new Promise((function(n){const r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){const t=iA(r.result),s={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,n(i.bufferViews.push(s)-1)}}))}processAccessor(t,e,i,n){const r=this.json;let s;if(t.array.constructor===Float32Array)s=Fd;else if(t.array.constructor===Int32Array)s=Nd;else if(t.array.constructor===Uint32Array)s=Qd;else if(t.array.constructor===Int16Array)s=Ud;else if(t.array.constructor===Uint16Array)s=Pd;else if(t.array.constructor===Int8Array)s=Ld;else{if(t.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);s=Dd}if(void 0===i&&(i=0),void 0===n&&(n=t.count),0===n)return null;const a=function(t,e,i){const n={min:new Array(t.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(t.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r4?i=t.array[r*t.itemSize+e]:(0===e?i=t.getX(r):1===e?i=t.getY(r):2===e?i=t.getZ(r):3===e&&(i=t.getW(r)),!0===t.normalized&&(i=Gt.normalize(i,t.array))),n.min[e]=Math.min(n.min[e],i),n.max[e]=Math.max(n.max[e],i)}return n}(t,i,n);let o;void 0!==e&&(o=t===e.index?kd:Od);const l=this.processBufferView(t,s,i,n,o),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:n,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[t.itemSize]};return!0===t.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(t,e,i,n="image/png"){if(null!==t){const r=this,s=r.cache,a=r.json,o=r.options,l=r.pending;s.images.has(t)||s.images.set(t,{});const c=s.images.get(t),h=n+":flipY/"+i.toString();if(void 0!==c[h])return c[h];a.images||(a.images=[]);const u={mimeType:n},d=nA();d.width=Math.min(t.width,o.maxTextureSize),d.height=Math.min(t.height,o.maxTextureSize);const A=d.getContext("2d");if(!0===i&&(A.translate(0,d.height),A.scale(1,-1)),void 0!==t.data){e!==k&&console.error("GLTFExporter: Only RGBAFormat is supported.",e),(t.width>o.maxTextureSize||t.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",t);const i=new Uint8ClampedArray(t.height*t.width*4);for(let e=0;er.processBufferViewImage(t))).then((t=>{u.bufferView=t}))):void 0!==d.toDataURL?u.uri=d.toDataURL(n):l.push(rA(d,n).then((t=>(new FileReader).readAsDataURL(t))).then((t=>{u.uri=t})));const p=a.images.push(u)-1;return c[h]=p,p}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const i={magFilter:Jd[t.magFilter],minFilter:Jd[t.minFilter],wrapS:Jd[t.wrapS],wrapT:Jd[t.wrapT]};return e.samplers.push(i)-1}processTexture(t){const e=this.options,i=this.cache,n=this.json;if(i.textures.has(t))return i.textures.get(t);n.textures||(n.textures=[]),t instanceof mo&&(t=Cd(t,e.maxTextureSize));let r=t.userData.mimeType;"image/webp"===r&&(r="image/png");const s={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,r)};t.name&&(s.name=t.name),this._invokeAll((function(e){e.writeTexture&&e.writeTexture(t,s)}));const a=n.textures.push(s)-1;return i.textures.set(t,a),a}processMaterial(t){const e=this.cache,i=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;i.materials||(i.materials=[]);const n={pbrMetallicRoughness:{}};!0!==t.isMeshStandardMaterial&&!0!==t.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=t.color.toArray().concat([t.opacity]);if(tA(r,[1,1,1,1])||(n.pbrMetallicRoughness.baseColorFactor=r),t.isMeshStandardMaterial?(n.pbrMetallicRoughness.metallicFactor=t.metalness,n.pbrMetallicRoughness.roughnessFactor=t.roughness):(n.pbrMetallicRoughness.metallicFactor=.5,n.pbrMetallicRoughness.roughnessFactor=.5),t.metalnessMap||t.roughnessMap){const e=this.buildMetalRoughTexture(t.metalnessMap,t.roughnessMap),i={index:this.processTexture(e),channel:e.channel};this.applyTextureTransform(i,e),n.pbrMetallicRoughness.metallicRoughnessTexture=i}if(t.map){const e={index:this.processTexture(t.map),texCoord:t.map.channel};this.applyTextureTransform(e,t.map),n.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){const e=t.emissive;if(Math.max(e.r,e.g,e.b)>0&&(n.emissiveFactor=t.emissive.toArray()),t.emissiveMap){const e={index:this.processTexture(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(e,t.emissiveMap),n.emissiveTexture=e}}if(t.normalMap){const e={index:this.processTexture(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&1!==t.normalScale.x&&(e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),n.normalTexture=e}if(t.aoMap){const e={index:this.processTexture(t.aoMap),texCoord:t.aoMap.channel};1!==t.aoMapIntensity&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),n.occlusionTexture=e}t.transparent?n.alphaMode="BLEND":t.alphaTest>0&&(n.alphaMode="MASK",n.alphaCutoff=t.alphaTest),t.side===c&&(n.doubleSided=!0),""!==t.name&&(n.name=t.name),this.serializeUserData(t,n),this._invokeAll((function(e){e.writeMaterial&&e.writeMaterial(t,n)}));const s=i.materials.push(n)-1;return e.materials.set(t,s),s}processMesh(t){const e=this.cache,i=this.json,n=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,i=t.material.length;e0){const i=[],n=[],r={};if(void 0!==t.morphTargetDictionary)for(const e in t.morphTargetDictionary)r[t.morphTargetDictionary[e]]=e;for(let a=0;a0&&(o.extras={},o.extras.targetNames=n)}const p=Array.isArray(t.material);if(p&&0===s.groups.length)return null;const m=p?t.material:[t.material],g=p?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let t=0,i=g.length;t0&&(i.targets=h),null!==s.index){let n=this.getUID(s.index);void 0===g[t].start&&void 0===g[t].count||(n+=":"+g[t].start+":"+g[t].count),e.attributes.has(n)?i.indices=e.attributes.get(n):(i.indices=this.processAccessor(s.index,s,g[t].start,g[t].count),e.attributes.set(n,i.indices)),null===i.indices&&delete i.indices}const n=this.processMaterial(m[g[t].materialIndex]);null!==n&&(i.material=n),c.push(i)}o.primitives=c,i.meshes||(i.meshes=[]),this._invokeAll((function(e){e.writeMesh&&e.writeMesh(t,o)}));const f=i.meshes.push(o)-1;return e.meshes.set(r,f),f}detectMeshQuantization(t,e){if(this.extensionsUsed[Kd])return;let i;switch(e.array.constructor){case Int8Array:i="byte";break;case Uint8Array:i="unsigned byte";break;case Int16Array:i="short";break;case Uint16Array:i="unsigned short";break;default:return}e.normalized&&(i+=" normalized");const n=t.split("_",1)[0];Id[n]&&Id[n].includes(i)&&(this.extensionsUsed[Kd]=!0,this.extensionsRequired[Kd]=!0)}processCamera(t){const e=this.json;e.cameras||(e.cameras=[]);const i=t.isOrthographicCamera,n={type:i?"orthographic":"perspective"};return i?n.orthographic={xmag:2*t.right,ymag:2*t.top,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:n.perspective={aspectRatio:t.aspect,yfov:Gt.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},""!==t.name&&(n.name=t.type),e.cameras.push(n)-1}processAnimation(t,e){const i=this.json,n=this.nodeMap;i.animations||(i.animations=[]);const r=(t=wd.Utils.mergeMorphTargetTracks(t.clone(),e)).tracks,s=[],a=[];for(let t=0;t0){const e=[];for(let n=0,r=t.children.length;n0&&(r.children=e)}this._invokeAll((function(e){e.writeNode&&e.writeNode(t,r)}));const s=e.nodes.push(r)-1;return n.set(t,s),s}processScene(t){const e=this.json,i=this.options;e.scenes||(e.scenes=[],e.scene=0);const n={};""!==t.name&&(n.name=t.name),e.scenes.push(n);const r=[];for(let e=0,n=t.children.length;e0&&(n.nodes=r),this.serializeUserData(t,n)}processObjects(t){const e=new ya;e.name="AuxScene";for(let i=0;i0&&this.processObjects(i);for(let t=0;t0&&(s.range=t.distance)):t.isSpotLight&&(s.type="spot",t.distance>0&&(s.range=t.distance),s.spot={},s.spot.innerConeAngle=(1-t.penumbra)*t.angle,s.spot.outerConeAngle=t.angle),void 0!==t.decay&&2!==t.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!t.target||t.target.parent===t&&0===t.target.position.x&&0===t.target.position.y&&-1===t.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(n.extensions=n.extensions||{},n.extensions[this.name]={lights:[]},r[this.name]=!0);const a=n.extensions[this.name].lights;a.push(s),e.extensions=e.extensions||{},e.extensions[this.name]={light:a.length-1}}}class oA{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}writeMaterial(t,e){if(!t.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},i[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class lA{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:i.processTexture(t.clearcoatMap),texCoord:t.clearcoatMap.channel};i.applyTextureTransform(e,t.clearcoatMap),r.clearcoatTexture=e}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:i.processTexture(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};i.applyTextureTransform(e,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:i.processTexture(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};i.applyTextureTransform(e,t.clearcoatNormalMap),r.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}}class cA{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:i.processTexture(t.iridescenceMap),texCoord:t.iridescenceMap.channel};i.applyTextureTransform(e,t.iridescenceMap),r.iridescenceTexture=e}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:i.processTexture(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};i.applyTextureTransform(e,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}}class hA{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){const e={index:i.processTexture(t.transmissionMap),texCoord:t.transmissionMap.channel};i.applyTextureTransform(e,t.transmissionMap),r.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}}class uA{constructor(t){this.writer=t,this.name="KHR_materials_volume"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){const e={index:i.processTexture(t.thicknessMap),texCoord:t.thicknessMap.channel};i.applyTextureTransform(e,t.thicknessMap),r.thicknessTexture=e}r.attenuationDistance=t.attenuationDistance,r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}}class dA{constructor(t){this.writer=t,this.name="KHR_materials_ior"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const i=this.writer.extensionsUsed,n={};n.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=n,i[this.name]=!0}}class AA{constructor(t){this.writer=t,this.name="KHR_materials_specular"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(Zd)&&!t.specularIntensityMap&&!t.specularColorTexture)return;const i=this.writer,n=i.extensionsUsed,r={};if(t.specularIntensityMap){const e={index:i.processTexture(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};i.applyTextureTransform(e,t.specularIntensityMap),r.specularTexture=e}if(t.specularColorMap){const e={index:i.processTexture(t.specularColorMap),texCoord:t.specularColorMap.channel};i.applyTextureTransform(e,t.specularColorMap),r.specularColorTexture=e}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}}class pA{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const i=this.writer,n=i.extensionsUsed,r={};if(t.sheenRoughnessMap){const e={index:i.processTexture(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};i.applyTextureTransform(e,t.sheenRoughnessMap),r.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:i.processTexture(t.sheenColorMap),texCoord:t.sheenColorMap.channel};i.applyTextureTransform(e,t.sheenColorMap),r.sheenColorTexture=e}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}}class mA{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const i=this.writer,n=i.extensionsUsed,r={};if(t.anisotropyMap){const e={index:i.processTexture(t.anisotropyMap)};i.applyTextureTransform(e,t.anisotropyMap),r.anisotropyTexture=e}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}}class gA{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}writeMaterial(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const i=this.writer.extensionsUsed,n={};n.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=n,i[this.name]=!0}}wd.Utils={insertKeyframe:function(t,e){const i=.001,n=t.getValueSize(),r=new t.TimeBufferType(t.times.length+1),s=new t.ValueBufferType(t.values.length+n),a=t.createInterpolant(new t.ValueBufferType(n));let o;if(0===t.times.length){r[0]=e;for(let t=0;tt.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)e){r.set(t.times.slice(0,l+1),0),r[l+1]=e,r.set(t.times.slice(l+1),l+2),s.set(t.values.slice(0,(l+1)*n),0),s.set(a.evaluate(e),(l+1)*n),s.set(t.values.slice((l+1)*n),(l+2)*n),o=l+1;break}}return t.times=r,t.values=s,o},mergeMorphTargetTracks:function(t,e){const i=[],n={},r=t.tracks;for(let t=0;tvoid 0!==t.material&&t.userData&&t.userData.variantMaterials&&!!Array.from(t.userData.variantMaterials.values()).filter((t=>vA(t.material))),vA=t=>t&&t.isMaterial&&!Array.isArray(t);class EA{constructor(t){this.writer=t,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(t){const e=new Set;for(const i of t)i.traverse((t=>{if(!fA(t))return;const i=t.userData.variantMaterials,n=t.userData.variantData;for(const[t,r]of n){const n=i.get(r.index);n&&vA(n.material)&&e.add(t)}}));e.forEach((t=>this.variantNames.push(t)))}writeMesh(t,e){if(!fA(t))return;const i=t.userData,n=i.variantMaterials,r=i.variantData,s=new Map,a=new Map,o=Array.from(r.values()).sort(((t,e)=>t.index-e.index));for(const[t,e]of o.entries())a.set(e.index,t);for(const t of r.values()){const e=n.get(t.index);if(!e||!vA(e.material))continue;const i=this.writer.processMaterial(e.material);s.has(i)||s.set(i,{material:i,variants:[]}),s.get(i).variants.push(a.get(t.index))}const l=Array.from(s.values()).map((t=>t.variants.sort(((t,e)=>t-e))&&t)).sort(((t,e)=>t.material-e.material));if(0===l.length)return;const c=vA(i.originalMaterial)?this.writer.processMaterial(i.originalMaterial):-1;for(const t of e.primitives)c>=0&&(t.material=c),t.extensions=t.extensions||{},t.extensions[this.name]={mappings:l}}afterParse(){if(0===this.variantNames.length)return;const t=this.writer.json;t.extensions=t.extensions||{};const e=this.variantNames.map((t=>({name:t})));t.extensions[this.name]={variants:e},this.writer.extensionsUsed[this.name]=!0}}class _A{constructor(t,e,i,n,r){this.xrLight=t,this.renderer=e,this.lightProbe=i,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const s=e.xr.getSession();if(n&&"XRWebGLBinding"in window){const i=new Dn(16);t.environment=i.texture;const n=e.getContext();switch(s.preferredReflectionFormat){case"srgba8":n.getExtension("EXT_sRGB");break;case"rgba16f":n.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(s,n),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}s.requestAnimationFrame(this.frameCallback)}updateReflection(){const t=this.renderer.properties.get(this.xrLight.environment);if(t){const e=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);e&&(t.__webglTexture=e,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(t,e){if(!this.xrLight)return;e.session.requestAnimationFrame(this.frameCallback);const i=e.getLightEstimate(this.lightProbe);if(i){this.xrLight.lightProbe.sh.fromArray(i.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const t=Math.max(1,Math.max(i.primaryLightIntensity.x,Math.max(i.primaryLightIntensity.y,i.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(i.primaryLightIntensity.x/t,i.primaryLightIntensity.y/t,i.primaryLightIntensity.z/t),this.xrLight.directionalLight.intensity=t,this.xrLight.directionalLight.position.copy(i.primaryLightDirection),this.estimationStartCallback&&(this.estimationStartCallback(),this.estimationStartCallback=null)}}dispose(){this.xrLight=null,this.renderer=null,this.lightProbe=null,this.xrWebGLBinding=null}}class yA extends Aa{constructor(t,e=!0){super(),this.lightProbe=new hl,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new ll,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let i=null,n=!1;t.xr.addEventListener("sessionstart",(()=>{const r=t.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then((r=>{i=new _A(this,t,r,e,(()=>{n=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),t.xr.addEventListener("sessionend",(()=>{i&&(i.dispose(),i=null),n&&this.dispatchEvent({type:"estimationend"})})),this.dispose=()=>{i&&(i.dispose(),i=null),this.remove(this.lightProbe),this.lightProbe=null,this.remove(this.directionalLight),this.directionalLight=null,this.environment=null}}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class xA{constructor(t=50){this.velocity=0,this.naturalFrequency=0,this.setDecayTime(t)}setDecayTime(t){this.naturalFrequency=1/Math.max(.001,t)}update(t,e,i,n){const r=2e-4*this.naturalFrequency;if(null==t||0===n)return e;if(t===e&&0===this.velocity)return e;if(i<0)return t;const s=t-e,a=this.velocity+this.naturalFrequency*s,o=s+i*a,l=Math.exp(-this.naturalFrequency*i),c=(a-this.naturalFrequency*o)*l,h=-this.naturalFrequency*(c+a*l);return Math.abs(c)=0?(this.velocity=0,e):(this.velocity=c,e+o*l)}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const SA=.2,CA=Math.PI/24,IA=new Ht,wA=(t,e,i)=>{let n=e>0?i>0?0:-Math.PI/2:i>0?Math.PI/2:Math.PI;for(let r=0;r<=12;++r)t.push(e+.17*Math.cos(n),i+.17*Math.sin(n),0,e+SA*Math.cos(n),i+SA*Math.sin(n),0),n+=CA};class MA extends _n{constructor(t,e){const i=new en,n=[],r=[],{size:s,boundingBox:a}=t,o=s.x/2,l=("back"===e?s.y:s.z)/2;wA(r,o,l),wA(r,-o,l),wA(r,-o,-l),wA(r,o,-l);const h=r.length/3;for(let t=0;t0}dispose(){var t;const{geometry:e,material:i}=this.hitPlane;e.dispose(),i.dispose(),this.geometry.dispose(),this.material.dispose(),null===(t=this.parent)||void 0===t||t.remove(this)}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const bA=(t,e)=>({type:"number",number:t,unit:e}),TA=(()=>{const t={};return e=>{const i=e;if(i in t)return t[i];const n=[];let r=0;for(;e;){if(++r>1e3){e="";break}const t=BA(e),i=t.nodes[0];if(null==i||0===i.terms.length)break;n.push(i),e=t.remainingInput}return t[i]=n}})(),BA=(()=>{const t=/^(\-\-|[a-z\u0240-\uffff])/i,e=/^([\*\+\/]|[\-]\s)/i,i=/^[\),]/;return n=>{const r=[];for(;n.length&&(n=n.trim(),!i.test(n));)if("("===n[0]){const{nodes:t,remainingInput:e}=UA(n);n=e,r.push({type:"function",name:{type:"ident",value:"calc"},arguments:t})}else if(t.test(n)){const t=RA(n),e=t.nodes[0];if("("===(n=t.remainingInput)[0]){const{nodes:t,remainingInput:i}=UA(n);r.push({type:"function",name:e,arguments:t}),n=i}else r.push(e)}else if(e.test(n))r.push({type:"operator",value:n[0]}),n=n.slice(1);else{const{nodes:t,remainingInput:e}="#"===n[0]?DA(n):LA(n);if(0===t.length)break;r.push(t[0]),n=e}return{nodes:[{type:"expression",terms:r}],remainingInput:n}}})(),RA=(()=>{const t=/[^a-z0-9_\-\u0240-\uffff]/i;return e=>{const i=e.match(t);return{nodes:[{type:"ident",value:null==i?e:e.substr(0,i.index)}],remainingInput:null==i?"":e.substr(i.index)}}})(),LA=(()=>{const t=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,e=/^[a-z%]+/i,i=/^(m|mm|cm|rad|deg|[%])$/;return n=>{const r=n.match(t),s=null==r?"0":r[0],a=(n=null==s?n:n.slice(s.length)).match(e);let o=null!=a&&""!==a[0]?a[0]:null;const l=null==a?n:n.slice(o.length);return null==o||i.test(o)||(o=null),{nodes:[{type:"number",number:parseFloat(s)||0,unit:o}],remainingInput:l}}})(),DA=(()=>{const t=/^[a-f0-9]*/i;return e=>{const i=(e=e.slice(1).trim()).match(t);return{nodes:null==i?[]:[{type:"hex",value:i[0]}],remainingInput:null==i?e:e.slice(i[0].length)}}})(),UA=t=>{const e=[];for(t=t.slice(1).trim();t.length;){const i=BA(t);if(e.push(i.nodes[0]),","===(t=i.remainingInput.trim())[0])t=t.slice(1).trim();else if(")"===t[0]){t=t.slice(1);break}}return{nodes:e,remainingInput:t}},PA=Symbol("visitedTypes");class NA{constructor(t){this[PA]=t}walk(t,e){const i=t.slice();for(;i.length;){const t=i.shift();switch(this[PA].indexOf(t.type)>-1&&e(t),t.type){case"expression":i.unshift(...t.terms);break;case"function":i.unshift(t.name,...t.arguments)}}}}const QA=Object.freeze({type:"number",number:0,unit:null}),FA=(t,e=0)=>{let{number:i,unit:n}=t;if(isFinite(i)){if("rad"===t.unit||null==t.unit)return t}else i=e,n="rad";return{type:"number",number:("deg"===n&&null!=i?i:0)*Math.PI/180,unit:"rad"}},OA=(t,e=0)=>{let i,{number:n,unit:r}=t;if(isFinite(n)){if("m"===t.unit)return t}else n=e,r="m";switch(r){default:i=1;break;case"cm":i=.01;break;case"mm":i=.001}return{type:"number",number:i*n,unit:"m"}},kA=(()=>{const t=t=>t,e={rad:t,deg:FA,m:t,mm:OA,cm:OA};return(t,i=QA)=>{isFinite(t.number)||(t.number=i.number,t.unit=i.unit);const{unit:n}=t;if(null==n)return t;const r=e[n];return null==r?i:r(t)}})(); +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var GA,HA,zA;const VA=Symbol("evaluate"),WA=Symbol("lastValue");class qA{constructor(){this[GA]=null}static evaluatableFor(t,e=QA){if(t instanceof qA)return t;if("number"===t.type)return"%"===t.unit?new YA(t,e):t;switch(t.name.value){case"calc":return new tp(t,e);case"env":return new JA(t)}return QA}static evaluate(t){return t instanceof qA?t.evaluate():t}static isConstant(t){return!(t instanceof qA)||t.isConstant}static applyIntrinsics(t,e){const{basis:i,keywords:n}=e,{auto:r}=n;return i.map(((e,i)=>{const s=null==r[i]?e:r[i];let a=t[i]?t[i]:s;if("ident"===a.type){const t=a.value;t in n&&(a=n[t][i])}return null!=a&&"ident"!==a.type||(a=s),"%"===a.unit?bA(a.number/100*e.number,e.unit):(a=kA(a,e),a.unit!==e.unit?e:a)}))}get isConstant(){return!1}evaluate(){return this.isConstant&&null!=this[WA]||(this[WA]=this[VA]()),this[WA]}}GA=WA;const XA=Symbol("percentage"),jA=Symbol("basis");class YA extends qA{constructor(t,e){super(),this[XA]=t,this[jA]=e}get isConstant(){return!0}[VA](){return bA(this[XA].number/100*this[jA].number,this[jA].unit)}}const KA=Symbol("identNode");class JA extends qA{constructor(t){super(),this[HA]=null;const e=t.arguments.length?t.arguments[0].terms[0]:null;null!=e&&"ident"===e.type&&(this[KA]=e)}get isConstant(){return!1}[(HA=KA,VA)](){if(null!=this[KA]&&"window-scroll-y"===this[KA].value){return{type:"number",number:window.pageYOffset/(Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)-window.innerHeight)||0,unit:null}}return QA}}const $A=/[\*\/]/,ZA=Symbol("evaluator");class tp extends qA{constructor(t,e=QA){if(super(),this[zA]=null,1!==t.arguments.length)return;const i=t.arguments[0].terms.slice(),n=[];for(;i.length;){const t=i.shift();if(n.length>0){const i=n[n.length-1];if("operator"===i.type&&$A.test(i.value)){const i=n.pop(),r=n.pop();if(null==r)return;n.push(new rp(i,qA.evaluatableFor(r,e),qA.evaluatableFor(t,e)));continue}}n.push("operator"===t.type?t:qA.evaluatableFor(t,e))}for(;n.length>2;){const[t,i,r]=n.splice(0,3);if("operator"!==i.type)return;n.unshift(new rp(i,qA.evaluatableFor(t,e),qA.evaluatableFor(r,e)))}1===n.length&&(this[ZA]=n[0])}get isConstant(){return null==this[ZA]||qA.isConstant(this[ZA])}[(zA=ZA,VA)](){return null!=this[ZA]?qA.evaluate(this[ZA]):QA}}const ep=Symbol("operator"),ip=Symbol("left"),np=Symbol("right");class rp extends qA{constructor(t,e,i){super(),this[ep]=t,this[ip]=e,this[np]=i}get isConstant(){return qA.isConstant(this[ip])&&qA.isConstant(this[np])}[VA](){const t=kA(qA.evaluate(this[ip])),e=kA(qA.evaluate(this[np])),{number:i,unit:n}=t,{number:r,unit:s}=e;if(null!=s&&null!=n&&s!=n)return QA;const a=n||s;let o;switch(this[ep].value){case"+":o=i+r;break;case"-":o=i-r;break;case"/":o=i/r;break;case"*":o=i*r;break;default:return QA}return{type:"number",number:o,unit:a}}}const sp=Symbol("evaluatables"),ap=Symbol("intrinsics");class op extends qA{constructor(t,e){super(),this[ap]=e;const i=t[0],n=null!=i?i.terms:[];this[sp]=e.basis.map(((t,e)=>{const i=n[e];return null==i?{type:"ident",value:"auto"}:"ident"===i.type?i:qA.evaluatableFor(i,t)}))}get isConstant(){for(const t of this[sp])if(!qA.isConstant(t))return!1;return!0}[VA](){const t=this[sp].map((t=>qA.evaluate(t)));return qA.applyIntrinsics(t,this[ap]).map((t=>t.number))}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var lp,cp,hp,up;const dp=Symbol("instances"),Ap=Symbol("activateListener"),pp=Symbol("deactivateListener"),mp=Symbol("notifyInstances"),gp=Symbol("notify"),fp=Symbol("callback");class vp{constructor(t){this[fp]=t}static[mp](){for(const t of vp[dp])t[gp]()}static[(lp=dp,Ap)](){window.addEventListener("scroll",this[mp],{passive:!0})}static[pp](){window.removeEventListener("scroll",this[mp])}observe(){0===vp[dp].size&&vp[Ap](),vp[dp].add(this)}disconnect(){vp[dp].delete(this),0===vp[dp].size&&vp[pp]()}[gp](){this[fp]()}}vp[lp]=new Set;const Ep=Symbol("computeStyleCallback"),_p=Symbol("astWalker"),yp=Symbol("dependencies"),xp=Symbol("onScroll");class Sp{constructor(t){this[cp]={},this[hp]=new NA(["function"]),this[up]=()=>{this[Ep]({relatedState:"window-scroll"})},this[Ep]=t}observeEffectsFor(t){const e={},i=this[yp];this[_p].walk(t,(t=>{const{name:n}=t,r=t.arguments[0].terms[0];if("env"===n.value&&null!=r&&"ident"===r.type&&"window-scroll-y"===r.value)if(null==e["window-scroll"]){const t="window-scroll"in i?i["window-scroll"]:new vp(this[xp]);t.observe(),delete i["window-scroll"],e["window-scroll"]=t}}));for(const t in i){i[t].disconnect()}this[yp]=e}dispose(){for(const t in this[yp]){this[yp][t].disconnect()}}}cp=yp,hp=_p,up=xp; +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const Cp=t=>{const e=t.observeEffects||!1,i=t.intrinsics instanceof Function?t.intrinsics:()=>t.intrinsics;return(n,r)=>{const s=n.updated,a=n.connectedCallback,o=n.disconnectedCallback,l=Symbol(`${r}StyleEffector`),c=Symbol(`${r}StyleEvaluator`),h=Symbol(`${r}UpdateEvaluator`),u=Symbol(`${r}EvaluateAndSync`);Object.defineProperties(n,{[l]:{value:null,writable:!0},[c]:{value:null,writable:!0},[h]:{value:function(){const t=TA(this[r]);this[c]=new op(t,i(this)),null==this[l]&&e&&(this[l]=new Sp((()=>this[u]()))),null!=this[l]&&this[l].observeEffectsFor(t)}},[u]:{value:function(){if(null==this[c])return;const e=this[c].evaluate();this[t.updateHandler](e)}},updated:{value:function(t){t.has(r)&&(this[h](),this[u]()),s.call(this,t)}},connectedCallback:{value:function(){a.call(this),this.requestUpdate(r,this[r])}},disconnectedCallback:{value:function(){o.call(this),null!=this[l]&&(this[l].dispose(),this[l]=null)}}})}},Ip=t=>t<.5?2*t*t:(4-2*t)*t-1,wp=(t,e,i=Ip)=>n=>t+(e-t)*i(n),Mp=t=>{const e=[],i=[];let n=t.initialValue;for(let r=0;r{const i=e.map((n=0,t=>n+=t));var n;return e=>{e=uh(e,0,1),e*=i[i.length-1];const n=i.findIndex((t=>t>=e)),r=n<1?0:i[n-1],s=i[n];return t[n]((e-r)/(s-r))}})(e,i)}; +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var bp=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const Tp=Mp({initialValue:0,keyframes:[{frames:5,value:-1},{frames:1,value:-1},{frames:8,value:1},{frames:1,value:1},{frames:5,value:0},{frames:18,value:0}]}),Bp=Mp({initialValue:0,keyframes:[{frames:1,value:1},{frames:5,value:1},{frames:1,value:0},{frames:6,value:0}]}),Rp="0deg 75deg 105%",Lp=["front","right","back","left"],Dp=["upper-","","lower-"],Up="auto",Pp="basic",Np="wiggle",Qp="none",Fp=()=>({basis:[FA(bA(30,"deg"))],keywords:{auto:[null]}}),Op=()=>({basis:[FA(bA(12,"deg"))],keywords:{auto:[null]}}),kp=(()=>{const t=TA(Rp)[0].terms,e=kA(t[0]),i=kA(t[1]);return t=>{const n=t[rE].idealCameraDistance();return{basis:[e,i,bA(n,"m")],keywords:{auto:[null,null,bA(105,"%")]}}}})(),Gp=t=>{const e=2.2*t[rE].boundingSphere.radius;return{basis:[bA(-1/0,"rad"),bA(Math.PI/8,"rad"),bA(e,"m")],keywords:{auto:[null,null,null]}}},Hp=t=>{const e=kp(t),i=new op([],e).evaluate()[2];return{basis:[bA(1/0,"rad"),bA(Math.PI-Math.PI/8,"rad"),bA(i,"m")],keywords:{auto:[null,null,null]}}},zp=t=>{const e=t[rE].boundingBox.getCenter(new ge);return{basis:[bA(e.x,"m"),bA(e.y,"m"),bA(e.z,"m")],keywords:{auto:[null,null,null]}}},Vp=Math.PI/2,Wp=Math.PI/3,qp=Vp/2,Xp=2*Math.PI,jp=Symbol("controls"),Yp=Symbol("panElement"),Kp=Symbol("promptElement"),Jp=Symbol("promptAnimatedContainer"),$p=Symbol("fingerAnimatedContainers"),Zp=Symbol("deferInteractionPrompt"),tm=Symbol("updateAria"),em=Symbol("updateCameraForRadius"),im=Symbol("cancelPrompts"),nm=Symbol("onChange"),rm=Symbol("onPointerChange"),sm=Symbol("waitingToPromptUser"),am=Symbol("userHasInteracted"),om=Symbol("promptElementVisibleTime"),lm=Symbol("lastPromptOffset"),cm=Symbol("cancellationSource"),hm=Symbol("lastSpherical"),um=Symbol("jumpCamera"),dm=Symbol("initialized"),Am=Symbol("maintainThetaPhi"),pm=Symbol("syncCameraOrbit"),mm=Symbol("syncFieldOfView"),gm=Symbol("syncCameraTarget"),fm=Symbol("syncMinCameraOrbit"),vm=Symbol("syncMaxCameraOrbit"),Em=Symbol("syncMinFieldOfView"),_m=Symbol("syncMaxFieldOfView"),ym=new Ht,xm=new ge,Sm=Object.freeze({minimumRadius:0,maximumRadius:1/0,minimumPolarAngle:Math.PI/8,maximumPolarAngle:Math.PI-Math.PI/8,minimumAzimuthalAngle:-1/0,maximumAzimuthalAngle:1/0,minimumFieldOfView:10,maximumFieldOfView:45,touchAction:"none"}),Cm=Math.PI/8,Im=.04,wm={USER_INTERACTION:"user-interaction",NONE:"none",AUTOMATIC:"automatic"};class Mm extends Mt{constructor(t,e,i){super(),this.camera=t,this.element=e,this.scene=i,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.inputSensitivity=1,this.changeSource=wm.NONE,this._interactionEnabled=!1,this._disableZoom=!1,this.isUserPointing=!1,this.enablePan=!0,this.enableTap=!0,this.panProjection=new zt,this.panPerPixel=0,this.spherical=new Ml,this.goalSpherical=new Ml,this.thetaDamper=new xA,this.phiDamper=new xA,this.radiusDamper=new xA,this.logFov=Math.log(Sm.maximumFieldOfView),this.goalLogFov=this.logFov,this.fovDamper=new xA,this.touchMode=null,this.pointers=[],this.startTime=0,this.startPointerPosition={clientX:0,clientY:0},this.lastSeparation=0,this.touchDecided=!1,this.onContext=t=>{if(this.enablePan)t.preventDefault();else for(const t of this.pointers)this.onPointerUp(new PointerEvent("pointercancel",Object.assign(Object.assign({},this.startPointerPosition),{pointerId:t.id})))},this.touchModeZoom=(t,e)=>{if(!this._disableZoom){const t=this.twoTouchDistance(this.pointers[0],this.pointers[1]),e=Im*this.zoomSensitivity*(this.lastSeparation-t)*50/this.scene.height;this.lastSeparation=t,this.userAdjustOrbit(0,0,e)}this.panPerPixel>0&&this.movePan(t,e)},this.disableScroll=t=>{t.preventDefault()},this.touchModeRotate=(t,e)=>{const{touchAction:i}=this._options;if(!this.touchDecided&&"none"!==i){this.touchDecided=!0;const n=Math.abs(t),r=Math.abs(e);if(this.changeSource===wm.USER_INTERACTION&&("pan-y"===i&&r>n||"pan-x"===i&&n>r))return void(this.touchMode=null);this.element.addEventListener("touchmove",this.disableScroll,{passive:!1})}this.handleSinglePointerMove(t,e)},this.onPointerDown=t=>{if(this.pointers.length>2)return;const{element:e}=this;0===this.pointers.length&&(e.addEventListener("pointermove",this.onPointerMove),e.addEventListener("pointerup",this.onPointerUp),this.touchMode=null,this.touchDecided=!1,this.startPointerPosition.clientX=t.clientX,this.startPointerPosition.clientY=t.clientY,this.startTime=performance.now());try{e.setPointerCapture(t.pointerId)}catch(t){}this.pointers.push({clientX:t.clientX,clientY:t.clientY,id:t.pointerId}),this.isUserPointing=!1,"touch"===t.pointerType?(this.changeSource=t.altKey?wm.AUTOMATIC:wm.USER_INTERACTION,this.onTouchChange(t)):(this.changeSource=wm.USER_INTERACTION,this.onMouseDown(t)),this.changeSource===wm.USER_INTERACTION&&this.dispatchEvent({type:"user-interaction"})},this.onPointerMove=t=>{const e=this.pointers.find((e=>e.id===t.pointerId));if(null==e)return;if("mouse"===t.pointerType&&0===t.buttons)return void this.onPointerUp(t);const i=this.pointers.length,n=(t.clientX-e.clientX)/i,r=(t.clientY-e.clientY)/i;0===n&&0===r||(e.clientX=t.clientX,e.clientY=t.clientY,"touch"===t.pointerType?(this.changeSource=t.altKey?wm.AUTOMATIC:wm.USER_INTERACTION,null!==this.touchMode&&this.touchMode(n,r)):(this.changeSource=wm.USER_INTERACTION,this.panPerPixel>0?this.movePan(n,r):this.handleSinglePointerMove(n,r)))},this.onPointerUp=t=>{const{element:e}=this,i=this.pointers.findIndex((e=>e.id===t.pointerId));-1!==i&&this.pointers.splice(i,1),this.panPerPixel>0&&!t.altKey&&this.resetRadius(),0===this.pointers.length?(e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),e.removeEventListener("touchmove",this.disableScroll),this.enablePan&&this.enableTap&&this.recenter(t)):null!==this.touchMode&&this.onTouchChange(t),this.scene.element[Yp].style.opacity=0,e.style.cursor="grab",this.panPerPixel=0,this.isUserPointing&&this.dispatchEvent({type:"pointer-change-end"})},this.onWheel=t=>{this.changeSource=wm.USER_INTERACTION;const e=t.deltaY*(1==t.deltaMode?18:1)*Im*this.zoomSensitivity/30;this.userAdjustOrbit(0,0,e),t.preventDefault(),this.dispatchEvent({type:"user-interaction"})},this.onKeyDown=t=>{const{changeSource:e}=this;this.changeSource=wm.USER_INTERACTION;(t.shiftKey&&this.enablePan?this.panKeyCodeHandler(t):this.orbitZoomKeyCodeHandler(t))?(t.preventDefault(),this.dispatchEvent({type:"user-interaction"})):this.changeSource=e},this._options=Object.assign({},Sm),this.setOrbit(0,Math.PI/2,1),this.setFieldOfView(100),this.jumpToGoal()}get interactionEnabled(){return this._interactionEnabled}enableInteraction(){if(!1===this._interactionEnabled){const{element:t}=this;t.addEventListener("pointerdown",this.onPointerDown),t.addEventListener("pointercancel",this.onPointerUp),this._disableZoom||t.addEventListener("wheel",this.onWheel),t.addEventListener("keydown",this.onKeyDown),t.addEventListener("touchmove",(()=>{}),{passive:!1}),t.addEventListener("contextmenu",this.onContext),this.element.style.cursor="grab",this._interactionEnabled=!0,this.updateTouchActionStyle()}}disableInteraction(){if(!0===this._interactionEnabled){const{element:t}=this;t.removeEventListener("pointerdown",this.onPointerDown),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),t.removeEventListener("pointercancel",this.onPointerUp),t.removeEventListener("wheel",this.onWheel),t.removeEventListener("keydown",this.onKeyDown),t.removeEventListener("contextmenu",this.onContext),t.style.cursor="",this.touchMode=null,this._interactionEnabled=!1,this.updateTouchActionStyle()}}get options(){return this._options}set disableZoom(t){this._disableZoom!=t&&(this._disableZoom=t,!0===t?this.element.removeEventListener("wheel",this.onWheel):this.element.addEventListener("wheel",this.onWheel),this.updateTouchActionStyle())}getCameraSpherical(t=new Ml){return t.copy(this.spherical)}getFieldOfView(){return this.camera.fov}applyOptions(t){Object.assign(this._options,t),this.setOrbit(),this.setFieldOfView(Math.exp(this.goalLogFov))}updateNearFar(t,e){this.camera.far=0===e?2:e,this.camera.near=Math.max(t,this.camera.far/1e3),this.camera.updateProjectionMatrix()}updateAspect(t){this.camera.aspect=t,this.camera.updateProjectionMatrix()}setOrbit(t=this.goalSpherical.theta,e=this.goalSpherical.phi,i=this.goalSpherical.radius){const{minimumAzimuthalAngle:n,maximumAzimuthalAngle:r,minimumPolarAngle:s,maximumPolarAngle:a,minimumRadius:o,maximumRadius:l}=this._options,{theta:c,phi:h,radius:u}=this.goalSpherical,d=uh(t,n,r);isFinite(n)||isFinite(r)||(this.spherical.theta=this.wrapAngle(this.spherical.theta-d)+d);const A=uh(e,s,a),p=uh(i,o,l);return(d!==c||A!==h||p!==u)&&(!!(isFinite(d)&&isFinite(A)&&isFinite(p))&&(this.goalSpherical.theta=d,this.goalSpherical.phi=A,this.goalSpherical.radius=p,this.goalSpherical.makeSafe(),!0))}setRadius(t){this.goalSpherical.radius=t,this.setOrbit()}setFieldOfView(t){const{minimumFieldOfView:e,maximumFieldOfView:i}=this._options;t=uh(t,e,i),this.goalLogFov=Math.log(t)}setDamperDecayTime(t){this.thetaDamper.setDecayTime(t),this.phiDamper.setDecayTime(t),this.radiusDamper.setDecayTime(t),this.fovDamper.setDecayTime(t)}adjustOrbit(t,e,i){const{theta:n,phi:r,radius:s}=this.goalSpherical,{minimumRadius:a,maximumRadius:o,minimumFieldOfView:l,maximumFieldOfView:c}=this._options,h=this.spherical.theta-n,u=Math.PI-.001,d=n-uh(t,-u-h,u-h),A=r-e,p=0===i?0:((i>0?o:a)-s)/(Math.log(i>0?c:l)-this.goalLogFov),m=s+i*(isFinite(p)?p:2*(o-a));if(this.setOrbit(d,A,m),0!==i){const t=this.goalLogFov+i;this.setFieldOfView(Math.exp(t))}}jumpToGoal(){this.update(0,1e4)}update(t,e){if(this.isStationary())return!1;const{maximumPolarAngle:i,maximumRadius:n}=this._options,r=this.spherical.theta-this.goalSpherical.theta;return Math.abs(r)>Math.PI&&!isFinite(this._options.minimumAzimuthalAngle)&&!isFinite(this._options.maximumAzimuthalAngle)&&(this.spherical.theta-=2*Math.sign(r)*Math.PI),this.spherical.theta=this.thetaDamper.update(this.spherical.theta,this.goalSpherical.theta,e,Math.PI),this.spherical.phi=this.phiDamper.update(this.spherical.phi,this.goalSpherical.phi,e,i),this.spherical.radius=this.radiusDamper.update(this.spherical.radius,this.goalSpherical.radius,e,n),this.logFov=this.fovDamper.update(this.logFov,this.goalLogFov,e,1),this.moveCamera(),!0}updateTouchActionStyle(){const{style:t}=this.element;if(this._interactionEnabled){const{touchAction:e}=this._options;this._disableZoom&&"none"!==e?t.touchAction="manipulation":t.touchAction=e}else t.touchAction=""}isStationary(){return this.goalSpherical.theta===this.spherical.theta&&this.goalSpherical.phi===this.spherical.phi&&this.goalSpherical.radius===this.spherical.radius&&this.goalLogFov===this.logFov}moveCamera(){this.spherical.makeSafe(),this.camera.position.setFromSpherical(this.spherical),this.camera.setRotationFromEuler(new ii(this.spherical.phi-Math.PI/2,this.spherical.theta,0,"YXZ")),this.camera.fov!==Math.exp(this.logFov)&&(this.camera.fov=Math.exp(this.logFov),this.camera.updateProjectionMatrix())}userAdjustOrbit(t,e,i){this.adjustOrbit(t*this.orbitSensitivity*this.inputSensitivity,e*this.orbitSensitivity*this.inputSensitivity,i*this.inputSensitivity)}wrapAngle(t){const e=(t+Math.PI)/(2*Math.PI);return 2*(e-Math.floor(e))*Math.PI-Math.PI}pixelLengthToSphericalAngle(t){return 2*Math.PI*t/this.scene.height}twoTouchDistance(t,e){const{clientX:i,clientY:n}=t,{clientX:r,clientY:s}=e,a=r-i,o=s-n;return Math.sqrt(a*a+o*o)}handleSinglePointerMove(t,e){const i=this.pixelLengthToSphericalAngle(t),n=this.pixelLengthToSphericalAngle(e);!1===this.isUserPointing&&(this.isUserPointing=!0,this.dispatchEvent({type:"pointer-change-start"})),this.userAdjustOrbit(i,n,0)}initializePan(){const{theta:t,phi:e}=this.spherical,i=t-this.scene.yaw;this.panPerPixel=.018*this.panSensitivity/this.scene.height,this.panProjection.set(-Math.cos(i),-Math.cos(e)*Math.sin(i),0,0,Math.sin(e),0,Math.sin(i),-Math.cos(e)*Math.cos(i),0)}movePan(t,e){const{scene:i}=this,n=xm.set(t,e,0).multiplyScalar(this.inputSensitivity),r=this.spherical.radius*Math.exp(this.logFov)*this.panPerPixel;n.multiplyScalar(r);const s=i.getTarget();s.add(n.applyMatrix3(this.panProjection)),i.boundingSphere.clampPoint(s,s),i.setTarget(s.x,s.y,s.z)}recenter(t){if(performance.now()>this.startTime+300||Math.abs(t.clientX-this.startPointerPosition.clientX)>2||Math.abs(t.clientY-this.startPointerPosition.clientY)>2)return;const{scene:e}=this,i=e.positionAndNormalFromPoint(e.getNDC(t.clientX,t.clientY));if(null==i){const{cameraTarget:t}=e.element;e.element.cameraTarget="",e.element.cameraTarget=t,this.userAdjustOrbit(0,0,1)}else e.target.worldToLocal(i.position),e.setTarget(i.position.x,i.position.y,i.position.z)}resetRadius(){const{scene:t}=this,e=t.positionAndNormalFromPoint(ym.set(0,0));if(null==e)return;t.target.worldToLocal(e.position);const i=t.getTarget(),{theta:n,phi:r}=this.spherical,s=n-t.yaw,a=xm.set(Math.sin(r)*Math.sin(s),Math.cos(r),Math.sin(r)*Math.cos(s)),o=a.dot(e.position.sub(i));i.add(a.multiplyScalar(o)),t.setTarget(i.x,i.y,i.z),this.setOrbit(void 0,void 0,this.goalSpherical.radius-o)}onTouchChange(t){if(1===this.pointers.length)this.touchMode=this.touchModeRotate;else{if(this._disableZoom)return this.touchMode=null,void this.element.removeEventListener("touchmove",this.disableScroll);this.touchMode=this.touchDecided&&null===this.touchMode?null:this.touchModeZoom,this.touchDecided=!0,this.element.addEventListener("touchmove",this.disableScroll,{passive:!1}),this.lastSeparation=this.twoTouchDistance(this.pointers[0],this.pointers[1]),this.enablePan&&null!=this.touchMode&&(this.initializePan(),t.altKey||(this.scene.element[Yp].style.opacity=1))}}onMouseDown(t){this.panPerPixel=0,this.enablePan&&(2===t.button||t.ctrlKey||t.metaKey||t.shiftKey)&&(this.initializePan(),this.scene.element[Yp].style.opacity=1),this.element.style.cursor="grabbing"}orbitZoomKeyCodeHandler(t){let e=!0;switch(t.key){case"PageUp":this.userAdjustOrbit(0,0,Im*this.zoomSensitivity);break;case"PageDown":this.userAdjustOrbit(0,0,-.04*this.zoomSensitivity);break;case"ArrowUp":this.userAdjustOrbit(0,-Cm,0);break;case"ArrowDown":this.userAdjustOrbit(0,Cm,0);break;case"ArrowLeft":this.userAdjustOrbit(-Cm,0,0);break;case"ArrowRight":this.userAdjustOrbit(Cm,0,0);break;default:e=!1}return e}panKeyCodeHandler(t){this.initializePan();let e=!0;switch(t.key){case"ArrowUp":this.movePan(0,-10);break;case"ArrowDown":this.movePan(0,10);break;case"ArrowLeft":this.movePan(-10,0);break;case"ArrowRight":this.movePan(10,0);break;default:e=!1}return e}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const bm="not-presenting",Tm="session-started",Bm="object-placed",Rm="failed",Lm="tracking",Dm="not-tracking",Um=new ge,Pm=new qe,Nm=new ge,Qm=new Tn(45,1,.1,100);class Fm extends Mt{constructor(t){super(),this.renderer=t,this.currentSession=null,this.placeOnWall=!1,this.placementBox=null,this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.initialHitSource=null,this.transientHitTestSource=null,this.inputSource=null,this._presentedScene=null,this.resolveCleanup=null,this.exitWebXRButtonContainer=null,this.overlay=null,this.xrLight=null,this.tracking=!0,this.frames=0,this.initialized=!1,this.oldTarget=new ge,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.lastDragPosition=new ge,this.firstRatio=0,this.lastAngle=0,this.goalPosition=new ge,this.goalYaw=0,this.goalScale=1,this.xDamper=new xA,this.yDamper=new xA,this.zDamper=new xA,this.yawDamper=new xA,this.scaleDamper=new xA,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onUpdateScene=()=>{null!=this.placementBox&&this.isPresenting&&(this.placementBox.dispose(),this.placementBox=new MA(this.presentedScene,this.placeOnWall?"back":"bottom"))},this.onSelectStart=t=>{const e=this.transientHitTestSource;if(null==e)return;const i=this.frame.getHitTestResultsForTransientInput(e),n=this.presentedScene,r=this.placementBox;if(1===i.length){this.inputSource=t.inputSource;const{axes:e}=this.inputSource.gamepad,i=r.getHit(this.presentedScene,e[0],e[1]);r.show=!0,null!=i?(this.isTranslating=!0,this.lastDragPosition.copy(i)):!1===this.placeOnWall&&(this.isRotating=!0,this.lastAngle=1.5*e[0])}else if(2===i.length){r.show=!0,this.isTwoFingering=!0;const{separation:t}=this.fingerPolar(i);this.firstRatio=t/n.scale.x}},this.onSelectEnd=()=>{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.inputSource=null,this.goalPosition.y+=this.placementBox.offsetHeight*this.presentedScene.scale.x,this.placementBox.show=!1},this.threeRenderer=t.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){lh();const t=await navigator.xr.requestSession("immersive-ar",{requiredFeatures:["hit-test"],optionalFeatures:["dom-overlay","light-estimation"],domOverlay:this.overlay?{root:this.overlay}:void 0});return this.threeRenderer.xr.setReferenceSpaceType("local"),await this.threeRenderer.xr.setSession(t),this.threeRenderer.xr.cameraAutoUpdate=!1,t}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return lh(),await navigator.xr.isSessionSupported("immersive-ar")}catch(t){return console.warn("Request to present in WebXR denied:"),console.warn(t),console.warn("Falling back to next ar-mode"),!1}}async present(t,e=!1){this.isPresenting&&console.warn("Cannot present while a model is already presenting");let i=new Promise(((t,e)=>{requestAnimationFrame((()=>t()))}));t.setHotspotsVisibility(!1),t.queueRender(),await i,this._presentedScene=t,this.overlay=t.element.shadowRoot.querySelector("div.default"),!0===e&&(this.xrLight=new yA(this.threeRenderer),this.xrLight.addEventListener("estimationstart",(()=>{if(!this.isPresenting||null==this.xrLight)return;const t=this.presentedScene;t.add(this.xrLight),t.environment=this.xrLight.environment})));const n=await this.resolveARSession();n.addEventListener("end",(()=>{this.postSessionCleanup()}),{once:!0});const r=t.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");r.classList.add("enabled"),r.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=r;const s=await n.requestReferenceSpace("viewer");this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=t.yaw,this.goalYaw=t.yaw,this.goalScale=1,t.background=null,this.oldShadowIntensity=t.shadowIntensity,t.setShadowIntensity(.01),this.oldTarget.copy(t.getTarget()),t.element.addEventListener("load",this.onUpdateScene);const a=20*Math.PI/180,o=!0===this.placeOnWall?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(a),z:-Math.cos(a)});n.requestHitTestSource({space:s,offsetRay:o}).then((t=>{this.initialHitSource=t})),this.currentSession=n,this.placementBox=new MA(t,this.placeOnWall?"back":"bottom"),this.placementComplete=!1,this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:Tm})}async stopPresenting(){if(!this.isPresenting)return;const t=new Promise((t=>{this.resolveCleanup=t}));try{await this.currentSession.end(),await t}catch(t){console.warn("Error while trying to end WebXR AR session"),console.warn(t),this.postSessionCleanup()}}get isPresenting(){return null!=this.presentedScene}get target(){return this.oldTarget}updateTarget(){const t=this.presentedScene;if(null!=t){const e=t.getTarget();this.oldTarget.copy(e),this.placeOnWall?e.z=t.boundingBox.min.z:e.y=t.boundingBox.min.y,t.setTarget(e.x,e.y,e.z)}}postSessionCleanup(){const t=this.currentSession;null!=t&&(t.removeEventListener("selectstart",this.onSelectStart),t.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const e=this.presentedScene;if(this._presentedScene=null,null!=e){const{element:t}=e;null!=this.xrLight&&(e.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),e.position.set(0,0,0),e.scale.set(1,1,1),e.setShadowOffset(0);const i=this.turntableRotation;null!=i&&(e.yaw=i);const n=this.oldShadowIntensity;null!=n&&e.setShadowIntensity(n),e.setEnvironmentAndSkybox(t[mh],t[gh]);const r=this.oldTarget;e.setTarget(r.x,r.y,r.z),e.xrCamera=null,e.element.removeEventListener("load",this.onUpdateScene),e.orientHotspots(0),t.requestUpdate("cameraTarget"),t.requestUpdate("maxCameraOrbit"),t[lE](t.getBoundingClientRect()),requestAnimationFrame((()=>{e.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:wm.NONE}}))}))}this.renderer.height=0;const i=this.exitWebXRButtonContainer;null!=i&&(i.classList.remove("enabled"),i.removeEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=null);const n=this.transientHitTestSource;null!=n&&(n.cancel(),this.transientHitTestSource=null);const r=this.initialHitSource;null!=r&&(r.cancel(),this.initialHitSource=null),null!=this.placementBox&&(this.placementBox.dispose(),this.placementBox=null),this.lastTick=null,this.turntableRotation=null,this.oldShadowIntensity=null,this.frame=null,this.inputSource=null,this.overlay=null,null!=this.resolveCleanup&&this.resolveCleanup(),this.dispatchEvent({type:"status",status:bm})}updateView(t){const e=this.presentedScene,i=this.threeRenderer.xr;i.updateCamera(Qm),e.xrCamera=i.getCamera();const{elements:n}=e.getCamera().matrixWorld;if(e.orientHotspots(Math.atan2(n[1],n[5])),this.initialized||(this.placeInitially(),this.initialized=!0),t.requestViewportScale&&t.recommendedViewportScale){const e=t.recommendedViewportScale;t.requestViewportScale(Math.max(e,.25))}const r=i.getBaseLayer();if(null!=r){const e=r instanceof XRWebGLLayer?r.getViewport(t):i.getBinding().getViewSubImage(r,t).viewport;this.threeRenderer.setViewport(e.x,e.y,e.width,e.height)}}placeInitially(){const t=this.presentedScene,{position:e,element:i}=t,n=t.getCamera(),{width:r,height:s}=this.overlay.getBoundingClientRect();t.setSize(r,s),n.projectionMatrixInverse.copy(n.projectionMatrix).invert();const{theta:a,radius:o}=i.getCameraOrbit(),l=n.getWorldDirection(Um);t.yaw=Math.atan2(-l.x,-l.z)-a,this.goalYaw=t.yaw,e.copy(n.position).add(l.multiplyScalar(o)),this.updateTarget();const c=t.getTarget();e.add(c).sub(this.oldTarget),this.goalPosition.copy(e),t.setHotspotsVisibility(!0);const{session:h}=this.frame;h.addEventListener("selectstart",this.onSelectStart),h.addEventListener("selectend",this.onSelectEnd),h.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then((t=>{this.transientHitTestSource=t}))}getTouchLocation(){const{axes:t}=this.inputSource.gamepad;let e=this.placementBox.getExpandedHit(this.presentedScene,t[0],t[1]);return null!=e&&(Um.copy(e).sub(this.presentedScene.getCamera().position),Um.length()>10)?null:e}getHitPoint(t){const e=this.threeRenderer.xr.getReferenceSpace(),i=t.getPose(e);if(null==i)return null;const n=Pm.fromArray(i.transform.matrix);return!0===this.placeOnWall&&(this.goalYaw=Math.atan2(n.elements[4],n.elements[6])),n.elements[5]>.75!==this.placeOnWall?Nm.setFromMatrixPosition(n):null}moveToFloor(t){const e=this.initialHitSource;if(null==e)return;const i=t.getHitTestResults(e);if(0==i.length)return;const n=i[0],r=this.getHitPoint(n);null!=r&&(this.placementBox.show=!0,this.isTranslating||(this.placeOnWall?this.goalPosition.copy(r):this.goalPosition.y=r.y),e.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:Bm}))}fingerPolar(t){const e=t[0].inputSource.gamepad.axes,i=t[1].inputSource.gamepad.axes,n=i[0]-e[0],r=i[1]-e[1],s=Math.atan2(r,n);let a=this.lastAngle-s;return a>Math.PI?a-=2*Math.PI:a<-Math.PI&&(a+=2*Math.PI),this.lastAngle=s,{separation:Math.sqrt(n*n+r*r),deltaYaw:a}}processInput(t){const e=this.transientHitTestSource;if(null==e)return;if(!this.isTranslating&&!this.isTwoFingering&&!this.isRotating)return;const i=t.getHitTestResultsForTransientInput(e),n=this.presentedScene,r=n.scale.x;if(this.isTwoFingering)if(i.length<2)this.isTwoFingering=!1;else{const{separation:t,deltaYaw:e}=this.fingerPolar(i);if(!1===this.placeOnWall&&(this.goalYaw+=e),n.canScale){const e=t/this.firstRatio;this.goalScale=e<1.3&&e>.7692307692307692?1:e}}else if(2!==i.length)if(this.isRotating){const t=1.5*this.inputSource.gamepad.axes[0];this.goalYaw+=t-this.lastAngle,this.lastAngle=t}else this.isTranslating&&i.forEach((t=>{if(t.inputSource!==this.inputSource)return;let e=null;if(t.results.length>0&&(e=this.getHitPoint(t.results[0])),null==e&&(e=this.getTouchLocation()),null!=e){if(this.goalPosition.sub(this.lastDragPosition),!1===this.placeOnWall){const t=e.y-this.lastDragPosition.y;if(t<0){this.placementBox.offsetHeight=t/r,this.presentedScene.setShadowOffset(t);const i=Um.copy(n.getCamera().position),s=-t/(i.y-e.y);i.multiplyScalar(s),e.multiplyScalar(1-s).add(i)}}this.goalPosition.add(e),this.lastDragPosition.copy(e)}}));else{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!0;const{separation:t}=this.fingerPolar(i);this.firstRatio=t/r}}moveScene(t){const e=this.presentedScene,{position:i,yaw:n}=e,r=e.boundingSphere.radius,s=this.goalPosition,a=e.scale.x,o=this.placementBox;let l=wm.NONE;if(!s.equals(i)||this.goalScale!==a){l=wm.USER_INTERACTION;let{x:n,y:c,z:h}=i;n=this.xDamper.update(n,s.x,t,r),c=this.yDamper.update(c,s.y,t,r),h=this.zDamper.update(h,s.z,t,r),i.set(n,c,h);const u=this.scaleDamper.update(a,this.goalScale,t,1);if(e.scale.set(u,u,u),!this.isTranslating){const t=s.y-c;this.placementComplete&&!1===this.placeOnWall?(o.offsetHeight=t/u,e.setShadowOffset(t)):0===t&&(this.placementComplete=!0,o.show=!1,e.setShadowIntensity(.8))}}o.updateOpacity(t),e.updateTarget(t),e.yaw=this.yawDamper.update(n,this.goalYaw,t,Math.PI),e.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:l}}))}onWebXRFrame(t,e){this.frame=e,++this.frames;const i=this.threeRenderer.xr.getReferenceSpace(),n=e.getViewerPose(i);null==n&&!0===this.tracking&&this.frames>30&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:Dm}));const r=this.presentedScene;if(null==n||null==r||!r.element.loaded)return void this.threeRenderer.clear();!1===this.tracking&&(this.tracking=!0,this.dispatchEvent({type:"tracking",status:Lm}));let s=!0;for(const i of n.views){if(this.updateView(i),s){this.moveToFloor(e),this.processInput(e);const i=t-this.lastTick;this.moveScene(i),this.renderer.preRender(r,t,i),this.lastTick=t,r.renderShadow(this.threeRenderer)}this.threeRenderer.render(r,r.getCamera()),s=!1}}}function Om(t){const e=new Map,i=new Map,n=t.clone();return km(t,n,(function(t,n){e.set(n,t),i.set(t,n)})),n.traverse((function(t){if(!t.isSkinnedMesh)return;const n=t,r=e.get(t),s=r.skeleton.bones;n.skeleton=r.skeleton.clone(),n.bindMatrix.copy(r.bindMatrix),n.skeleton.bones=s.map((function(t){return i.get(t)})),n.bind(n.skeleton,n.bindMatrix)})),n}function km(t,e,i){i(t,e);for(let n=0;n{t.traverse((t=>{const e=t;if(!e.material)return;(Array.isArray(e.material)?e.material:[e.material]).forEach((t=>{for(const e in t){const i=t[e];if(i instanceof ce){const t=i.source.data;null!=t.close&&t.close(),i.dispose()}}t.dispose()})),e.geometry.dispose()}))}))}[Vm](){const t=this[zm],e=Om(this.scene);qm(e,this.scene);const i=[e],n=t.userData?Object.assign({},t.userData):{};return Object.assign(Object.assign({},t),{scene:e,scenes:i,userData:n})}}const qm=(t,e)=>{Xm(t,e,((t,e)=>{void 0!==e.userData.variantMaterials&&(t.userData.variantMaterials=new Map(e.userData.variantMaterials)),void 0!==e.userData.variantData&&(t.userData.variantData=e.userData.variantData),void 0!==e.userData.originalMaterial&&(t.userData.originalMaterial=e.userData.originalMaterial)}))},Xm=(t,e,i)=>{i(t,e);for(let n=0;n{const n=e.threeObjectMap.get(t);if(null!=n)for(const t in n)if(null!=t&&"primitives"!==t){const e=t,o=n[e],l=r[e][o],c=s.get(i)||{};c[e]=o,s.set(i,c);const h=a.get(l)||new Set;h.add(i),a.set(l,h)}}));return new eg(t,r,s,a)}static[$m](t,e,i){const n=(t,e)=>{if(i(t,e),t.isObject3D){const r=t,s=e;if(r.material)if(Array.isArray(r.material))for(let t=0;t{t.renderOrder=1e3,t.frustumCulled=!1,t.name||(t.name=t.uuid);const i=t;if(i.material){const{geometry:t}=i;i.castShadow=!0,i.isSkinnedMesh&&(t.boundingSphere=n,t.boundingBox=null);const r=i.material;if(!0===r.isMeshBasicMaterial&&(r.toneMapped=!1),r.shadowSide=o,r.aoMap){const{gltf:i,threeObjectMap:n}=e[ig],s=n.get(r);if(null!=i.materials&&null!=s&&null!=s.materials){const e=i.materials[s.materials];e.occlusionTexture&&0===e.occlusionTexture.texCoord&&null!=t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv)}}}})),e}get correlatedSceneGraph(){return this[zm][ig]}[Vm](){const t=super[Vm](),e=new Map;return t.scene.traverse((t=>{const i=t;if(i.material){const t=i.material;if(null!=t){if(e.has(t.uuid))return void(i.material=e.get(t.uuid));i.material=t.clone(),e.set(t.uuid,i.material)}}const n=t;void 0!==n.target&&n.add(n.target)})),t[ig]=eg.from(t,this.correlatedSceneGraph),t}}class rg extends Xo{constructor(t){super(t),this.type=F}parse(t){const e=function(t,e){switch(t){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(e||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(e||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(e||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(e||""))}},i=function(t,e,i){e=e||1024;let n=t.pos,r=-1,s=0,a="",o=String.fromCharCode.apply(null,new Uint16Array(t.subarray(n,n+128)));for(;0>(r=o.indexOf("\n"))&&s=t.byteLength||!(l=i(t)))&&e(1,"no header found"),(c=l.match(/^#\?(\S+)/))||e(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=i(t),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(n))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(s))&&(o.valid|=2,o.format=c[1]),(c=l.match(a))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||e(3,"missing format specifier"),4&o.valid||e(3,"missing image size specifier"),o}(s),o=a.width,l=a.height,c=function(t,i,n){const r=i;if(r<8||r>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);r!==(t[2]<<8|t[3])&&e(3,"wrong scanline width");const s=new Uint8Array(4*i*n);s.length||e(4,"unable to allocate buffer space");let a=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let u=n;for(;u>0&&ot.byteLength&&e(1),c[0]=t[o++],c[1]=t[o++],c[2]=t[o++],c[3]=t[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==r||e(3,"bad rgbe scanline format");let i,n=0;for(;n128;if(r&&(i-=128),(0===i||n+i>l)&&e(3,"bad scanline data"),r){const e=t[o++];for(let t=0;tthis.ldrLoader.load(t,e,(()=>{}),i)));return e.name=t,e.flipY=!1,e}async loadLottie(t,e){const i=await this.getLottieLoader();i.setQuality(e);const n=await new Promise(((e,n)=>i.load(t,e,(()=>{}),n)));return n.name=t,n}async loadEquirect(t,e=(()=>{})){try{const i=lg.test(t),n=i?this.hdrLoader:this.ldrLoader,r=await new Promise(((i,r)=>n.load(t,i,(t=>{e(t.loaded/t.total*.9)}),r)));return e(1),r.name=t,r.mapping=x,i||(r.colorSpace=At),r}finally{e&&e(1)}}async generateEnvironmentMapAndSkybox(t=null,e=null,i=(()=>{})){const n="legacy"!==e;"legacy"!==e&&"neutral"!==e||(e=null),e=oh(e);let r,s=Promise.resolve(null);t&&(s=this.loadEquirectFromUrl(t,i)),r=e?this.loadEquirectFromUrl(e,i):t?this.loadEquirectFromUrl(t,i):n?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[a,o]=await Promise.all([r,s]);if(null==a)throw new Error("Failed to load environment map.");return{environmentMap:a,skybox:o}}async loadEquirectFromUrl(t,e){if(!this.skyboxCache.has(t)){const i=this.loadEquirect(t,e);this.skyboxCache.set(t,i)}return this.skyboxCache.get(t)}async GenerateEnvironmentMap(t,e){await((t=0)=>new Promise((e=>setTimeout(e,t))))();const i=this.threeRenderer,n=new Dn(256,{generateMipmaps:!1,type:F,format:k,colorSpace:pt,depthBuffer:!0}),r=new Rn(.1,100,n),s=r.renderTarget.texture;s.name=e;const a=i.outputColorSpace,o=i.toneMapping;return i.toneMapping=p,i.outputColorSpace=pt,r.update(i,t),this.blurCubemap(n,.04),i.toneMapping=o,i.outputColorSpace=a,s}async loadGeneratedEnvironmentMap(){return null==this.generatedEnvironmentMap&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new sg,"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return null==this.generatedEnvironmentMapAlt&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new ag,"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(t,e){if(null==this.blurMaterial){this.blurMaterial=this.getBlurShader(og);const t=new xn,e=new _n(t,this.blurMaterial);this.blurScene=new ya,this.blurScene.add(e)}const i=t.clone();this.halfblur(t,i,e,"latitudinal"),this.halfblur(i,t,e,"longitudinal")}halfblur(t,e,i,n){const r=t.width,s=isFinite(i)?Math.PI/(2*r):2*Math.PI/39,a=i/s,o=isFinite(i)?1+Math.floor(3*a):og;o>og&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${o} samples when the maximum is set to 20`);const l=[];let c=0;for(let t=0;t= samples ) {\n \n break;\n \n }\n \n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n \n }\n }\n ",blending:0,depthTest:!1,depthWrite:!1,side:l})}async dispose(){for(const[,t]of this.skyboxCache){(await t).dispose()}null!=this.generatedEnvironmentMap&&((await this.generatedEnvironmentMap).dispose(),this.generatedEnvironmentMap=null),null!=this.generatedEnvironmentMapAlt&&((await this.generatedEnvironmentMapAlt).dispose(),this.generatedEnvironmentMapAlt=null),null!=this.blurMaterial&&this.blurMaterial.dispose()}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const hg=[1,.79,.62,.5,.4,.31,.25],ug="high-performance";class dg extends Mt{constructor(t){super(),this.loader=new ud(ng),this.width=0,this.height=0,this.dpr=1,this.scenes=new Set,this.multipleScenesVisible=!1,this.lastTick=performance.now(),this.renderedLastFrame=!1,this.scaleStep=0,this.lastStep=3,this.avgFrameDuration=50,this.onWebGLContextLost=t=>{this.dispatchEvent({type:"contextlost",sourceEvent:t})},this.onWebGLContextRestored=()=>{var t;null===(t=this.textureUtils)||void 0===t||t.dispose(),this.textureUtils=new cg(this.threeRenderer);for(const t of this.scenes)t.element[fh]()},this.dpr=dh(),this.canvas3D=document.createElement("canvas"),this.canvas3D.id="webgl-canvas",this.canvas3D.classList.add("show"),Vn.tonemapping_pars_fragment=Vn.tonemapping_pars_fragment.replace("vec3 CustomToneMapping( vec3 color ) { return color; }","\n float startCompression = 0.8;\n float desaturation = 0.5;\n vec3 CustomToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n \n float d = 1. - startCompression;\n\n float peak = max(color.r, max(color.g, color.b));\n if (peak < startCompression) return color;\n\n float newPeak = 1. - d * d / (peak + d - startCompression);\n float invPeak = 1. / peak;\n \n float extraBrightness = dot(color * (1. - startCompression * invPeak), vec3(1, 1, 1));\n \n color *= newPeak * invPeak;\n float g = 1. - 3. / (desaturation * extraBrightness + 3.);\n return mix(color, vec3(1, 1, 1), g);\n }");try{this.threeRenderer=new _a({canvas:this.canvas3D,alpha:!0,antialias:!0,powerPreference:t.powerPreference,preserveDrawingBuffer:!0}),this.threeRenderer.autoClear=!0,this.threeRenderer.setPixelRatio(1),this.threeRenderer.debug={checkShaderErrors:!!t.debug,onShaderError:null},this.threeRenderer.toneMapping=v}catch(t){console.warn(t)}this.arRenderer=new Fm(this),this.textureUtils=this.canRender?new cg(this.threeRenderer):null,ud.initializeKTX2Loader(this.threeRenderer),this.canvas3D.addEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.addEventListener("webglcontextrestored",this.onWebGLContextRestored),this.updateRendererSize()}static get singleton(){return this._singleton}static resetSingleton(){const t=this._singleton.dispose();for(const e of t)e.disconnectedCallback();this._singleton=new dg({powerPreference:(self.ModelViewerElement||{}).powerPreference||ug,debug:Ah()});for(const e of t)e.connectedCallback()}get canRender(){return null!=this.threeRenderer}get scaleFactor(){return hg[this.scaleStep]}set minScale(t){let e=1;for(;e0&&this.threeRenderer.setAnimationLoop(((t,e)=>this.render(t,e)))}unregisterScene(t){this.scenes.delete(t),this.canvas3D.parentElement===t.canvas.parentElement&&t.canvas.parentElement.removeChild(this.canvas3D),this.canRender&&0===this.scenes.size&&this.threeRenderer.setAnimationLoop(null)}displayCanvas(t){return this.multipleScenesVisible?t.element[nE]:this.canvas3D}countVisibleScenes(){const{canvas3D:t}=this;let e=0,i=null;for(const n of this.scenes){const{element:r}=n;r.modelIsVisible&&null==n.externalRenderer&&++e,t.parentElement===n.canvas.parentElement&&(i=n)}const n=e>1;if(null!=i){const e=n&&!this.multipleScenesVisible,r=!i.element.modelIsVisible;if(e||r){const{width:e,height:n}=this.sceneSize(i);this.copyPixels(i,e,n),t.parentElement.removeChild(t)}}this.multipleScenesVisible=n}updateRendererSize(){var t;const e=dh();if(e!==this.dpr)for(const t of this.scenes){const{element:e}=t;e[Vv](e.getBoundingClientRect())}let i=0,n=0;for(const t of this.scenes)i=Math.max(i,t.width),n=Math.max(n,t.height);if(i!==this.width||n!==this.height||e!==this.dpr){this.width=i,this.height=n,this.dpr=e,i=Math.ceil(i*e),n=Math.ceil(n*e),this.canRender&&this.threeRenderer.setSize(i,n,!1);for(const e of this.scenes){const{canvas:r}=e;r.width=i,r.height=n,e.forceRescale(),null===(t=e.effectRenderer)||void 0===t||t.setSize(i,n)}}}updateRendererScale(t){const e=this.scaleStep;this.avgFrameDuration+=uh(.2*(t-this.avgFrameDuration),-5,5),this.avgFrameDuration>60?++this.scaleStep:this.avgFrameDuration<40&&this.scaleStep>0&&--this.scaleStep,this.scaleStep=Math.min(this.scaleStep,this.lastStep),e!==this.scaleStep&&(this.avgFrameDuration=50)}shouldRender(t){if(t.shouldRender())t.scaleStep!=this.scaleStep&&(t.scaleStep=this.scaleStep,this.rescaleCanvas(t));else{if(0==t.scaleStep)return!1;t.scaleStep=0,this.rescaleCanvas(t)}return!0}rescaleCanvas(t){const e=hg[t.scaleStep],i=Math.ceil(this.width/e),n=Math.ceil(this.height/e),{style:r}=t.canvas;r.width=`${i}px`,r.height=`${n}px`,this.canvas3D.style.width=`${i}px`,this.canvas3D.style.height=`${n}px`;const s=this.dpr*e,a=e<1?"GPU throttling":this.dpr!==window.devicePixelRatio?"No meta viewport tag":"";t.element.dispatchEvent(new CustomEvent("render-scale",{detail:{reportedDpr:window.devicePixelRatio,renderedDpr:s,minimumDpr:this.dpr*hg[this.lastStep],pixelWidth:Math.ceil(t.width*s),pixelHeight:Math.ceil(t.height*s),reason:a}}))}sceneSize(t){const{dpr:e}=this,i=hg[t.scaleStep];return{width:Math.min(Math.ceil(t.width*i*e),this.canvas3D.width),height:Math.min(Math.ceil(t.height*i*e),this.canvas3D.height)}}copyPixels(t,e,i){const n=t.context;null!=n?(n.clearRect(0,0,e,i),n.drawImage(this.canvas3D,0,0,e,i,0,0,e,i),t.canvas.classList.add("show")):console.log("could not acquire 2d context")}orderedScenes(){const t=[];for(const e of[!1,!0])for(const i of this.scenes)i.element.modelIsVisible===e&&t.push(i);return t}get isPresenting(){return this.arRenderer.isPresenting}preRender(t,e,i){const{element:n,exposure:r}=t;n[aE](e,i);const s="number"==typeof r&&!Number.isNaN(r);this.threeRenderer.toneMappingExposure=s?r:1}render(t,e){if(null!=e)return void this.arRenderer.onWebXRFrame(t,e);const i=t-this.lastTick;if(this.lastTick=t,!this.canRender||this.isPresenting)return;this.countVisibleScenes(),this.updateRendererSize(),this.renderedLastFrame&&(this.updateRendererScale(i),this.renderedLastFrame=!1);const{canvas3D:n}=this;for(const e of this.orderedScenes()){const{element:r}=e;if(!r.loaded||!r.modelIsVisible&&e.renderCount>0)continue;if(this.preRender(e,t,i),!this.shouldRender(e))continue;if(null!=e.externalRenderer){const t=e.getCamera();t.updateMatrix();const{matrix:i,projectionMatrix:n}=t,r=i.elements.slice(),s=e.getTarget();r[12]+=s.x,r[13]+=s.y,r[14]+=s.z,e.externalRenderer.render({viewMatrix:r,projectionMatrix:n.elements});continue}if(!r.modelIsVisible&&!this.multipleScenesVisible)for(const t of this.scenes)t.element.modelIsVisible&&t.queueRender();const{width:s,height:a}=this.sceneSize(e);e.renderShadow(this.threeRenderer),this.threeRenderer.setRenderTarget(null),this.threeRenderer.setViewport(0,Math.ceil(this.height*this.dpr)-a,s,a),null!=e.effectRenderer?e.effectRenderer.render(i):(this.threeRenderer.autoClear=!0,this.threeRenderer.toneMapping="commerce"===e.toneMapping?E:v,this.threeRenderer.render(e,e.camera)),this.multipleScenesVisible||!e.element.modelIsVisible&&0===e.renderCount?this.copyPixels(e,s,a):n.parentElement!==e.canvas.parentElement&&(e.canvas.parentElement.appendChild(n),e.canvas.classList.remove("show")),e.hasRendered(),++e.renderCount,this.renderedLastFrame=!0}}dispose(){null!=this.textureUtils&&this.textureUtils.dispose(),null!=this.threeRenderer&&this.threeRenderer.dispose(),this.textureUtils=null,this.threeRenderer=null;const t=[];for(const e of this.scenes)t.push(e.element);return this.canvas3D.removeEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.removeEventListener("webglcontextrestored",this.onWebGLContextRestored),t}}dg._singleton=new dg({powerPreference:(self.ModelViewerElement||{}).powerPreference||ug,debug:Ah()}); +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const Ag=Symbol("correlatedObjects"),pg=Symbol("onUpdate");class mg{constructor(t,e=null){this[pg]=t,this[Ag]=e}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const gg=new Fi,fg=new zn(2,2);let vg=0;const Eg=Symbol("threeTexture"),_g=Symbol("threeTextures");class yg extends mg{get[Eg](){var t;return null===(t=this[Ag])||void 0===t?void 0:t.values().next().value}get[_g](){return this[Ag]}constructor(t,e){super(t,new Set(e?[e]:[])),this[Eg].image.src||(this[Eg].image.src="adhoc_image"+vg++),this[Eg].image.name||(this[Eg].image.name=e&&e.image&&e.image.src?e.image.src.split("/").pop():"adhoc_image")}get name(){return this[Eg].image.name||""}get uri(){return this[Eg].image.src}get bufferView(){return this[Eg].image.bufferView}get element(){const t=this[Eg];if(t&&(t.isCanvasTexture||t.isVideoTexture))return t.image}get animation(){const t=this[Eg];if(t&&t.isCanvasTexture&&t.animation)return t.animation}get type(){return null!=this.uri?"external":"embedded"}set name(t){for(const e of this[_g])e.image.name=t}update(){const t=this[Eg];t&&t.isCanvasTexture&&!t.animation&&(this[Eg].needsUpdate=!0,this[pg]())}async createThumbnail(t,e){const i=new ya;gg.map=this[Eg];const n=new _n(fg,gg);i.add(n);const r=new tr(-1,1,1,-1,0,1),{threeRenderer:s}=dg.singleton,a=new de(t,e);s.setRenderTarget(a),s.render(i,r),s.setRenderTarget(null);const o=new Uint8Array(t*e*4);s.readRenderTargetPixels(a,0,0,t,e,o),Uv.width=t,Uv.height=e;const l=Uv.getContext("2d"),c=l.createImageData(t,e);return c.data.set(o),l.putImageData(c,0,0),new Promise((async(t,e)=>{Uv.toBlob((i=>{if(!i)return e("Failed to capture thumbnail.");t(URL.createObjectURL(i))}),"image/png")}))}}var xg,Sg;!function(t){t[t.Nearest=9728]="Nearest",t[t.Linear=9729]="Linear",t[t.NearestMipmapNearest=9984]="NearestMipmapNearest",t[t.LinearMipmapNearest=9985]="LinearMipmapNearest",t[t.NearestMipmapLinear=9986]="NearestMipmapLinear",t[t.LinearMipmapLinear=9987]="LinearMipmapLinear"}(xg||(xg={})),function(t){t[t.ClampToEdge=33071]="ClampToEdge",t[t.MirroredRepeat=33648]="MirroredRepeat",t[t.Repeat=10497]="Repeat"}(Sg||(Sg={})); +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const Cg=new Map([[Sg.Repeat,C],[Sg.ClampToEdge,I],[Sg.MirroredRepeat,w]]),Ig=new Map([[C,Sg.Repeat],[I,Sg.ClampToEdge],[w,Sg.MirroredRepeat]]),wg=new Map([[xg.Nearest,M],[xg.Linear,B],[xg.NearestMipmapNearest,b],[xg.LinearMipmapNearest,R],[xg.NearestMipmapLinear,T],[xg.LinearMipmapLinear,L]]),Mg=new Map([[M,xg.Nearest],[B,xg.Linear],[b,xg.NearestMipmapNearest],[R,xg.LinearMipmapNearest],[T,xg.NearestMipmapLinear],[L,xg.LinearMipmapLinear]]),bg=new Map([[xg.Nearest,M],[xg.Linear,B]]),Tg=new Map([[M,xg.Nearest],[B,xg.Linear]]),Bg=t=>Mg.has(t),Rg=t=>Tg.has(t),Lg=t=>Ig.has(t),Dg=Symbol("threeTexture"),Ug=Symbol("threeTextures"),Pg=Symbol("setProperty");class Ng extends mg{get[Dg](){var t;return null===(t=this[Ag])||void 0===t?void 0:t.values().next().value}get[Ug](){return this[Ag]}constructor(t,e){super(t,new Set(e?[e]:[]))}get name(){return this[Dg].name||""}get minFilter(){return Mg.get(this[Dg].minFilter)}get magFilter(){return Tg.get(this[Dg].magFilter)}get wrapS(){return Ig.get(this[Dg].wrapS)}get wrapT(){return Ig.get(this[Dg].wrapT)}get rotation(){return this[Dg].rotation}get scale(){return mE(this[Dg].repeat)}get offset(){return mE(this[Dg].offset)}setMinFilter(t){this[Pg]("minFilter",wg.get(t))}setMagFilter(t){this[Pg]("magFilter",bg.get(t))}setWrapS(t){this[Pg]("wrapS",Cg.get(t))}setWrapT(t){this[Pg]("wrapT",Cg.get(t))}setRotation(t){null==t&&(t=0),this[Pg]("rotation",t)}setScale(t){null==t&&(t={u:1,v:1}),this[Pg]("repeat",new Ht(t.u,t.v))}setOffset(t){null==t&&(t={u:0,v:0}),this[Pg]("offset",new Ht(t.u,t.v))}[Pg](t,e){if(((t,e)=>{switch(t){case"minFilter":return Bg(e);case"magFilter":return Rg(e);case"wrapS":case"wrapT":return Lg(e);case"rotation":case"repeat":case"offset":return!0;default:throw new Error(`Cannot configure property "${t}" on Sampler`)}})(t,e))for(const i of this[Ug])i[t]=e,i.needsUpdate=!0;this[pg]()}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const Qg=Symbol("image"),Fg=Symbol("sampler"),Og=Symbol("threeTexture");class kg extends mg{constructor(t,e){super(t,new Set(e?[e]:[])),this[Fg]=new Ng(t,e),this[Qg]=new yg(t,e)}get[Og](){var t;return null===(t=this[Ag])||void 0===t?void 0:t.values().next().value}get name(){return this[Og].name||""}set name(t){for(const e of this[Ag])e.name=t}get sampler(){return this[Fg]}get source(){return this[Qg]}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var Gg,Hg,zg;const Vg=Symbol("texture"),Wg=Symbol("transform"),qg=Symbol("materials"),Xg=Symbol("usage"),jg=Symbol("onUpdate"),Yg=Symbol("activeVideo");var Kg;!function(t){t[t.Base=0]="Base",t[t.MetallicRoughness=1]="MetallicRoughness",t[t.Normal=2]="Normal",t[t.Occlusion=3]="Occlusion",t[t.Emissive=4]="Emissive",t[t.Clearcoat=5]="Clearcoat",t[t.ClearcoatRoughness=6]="ClearcoatRoughness",t[t.ClearcoatNormal=7]="ClearcoatNormal",t[t.SheenColor=8]="SheenColor",t[t.SheenRoughness=9]="SheenRoughness",t[t.Transmission=10]="Transmission",t[t.Thickness=11]="Thickness",t[t.Specular=12]="Specular",t[t.SpecularColor=13]="SpecularColor",t[t.Iridescence=14]="Iridescence",t[t.IridescenceThickness=15]="IridescenceThickness",t[t.Anisotropy=16]="Anisotropy"}(Kg||(Kg={}));class Jg{constructor(t,e,i,n){this[Gg]=null,this[Hg]={rotation:0,scale:new Ht(1,1),offset:new Ht(0,0)},this[zg]=!1,i&&(this[Wg].rotation=i.rotation,this[Wg].scale.copy(i.repeat),this[Wg].offset.copy(i.offset),this[Vg]=new kg(t,i)),this[jg]=t,this[qg]=n,this[Xg]=e}get texture(){return this[Vg]}setTexture(t){var e,i;const n=null!=t?t.source[Eg]:null,r=null===(e=this[Vg])||void 0===e?void 0:e.source[Eg];if(null!=r&&r.isVideoTexture?this[Yg]=!1:(null===(i=this[Vg])||void 0===i?void 0:i.source.animation)&&this[Vg].source.animation.removeEventListener("enterFrame",this[jg]),this[Vg]=t,null!=n&&n.isVideoTexture){const t=n.image;if(this[Yg]=!0,null!=t.requestVideoFrameCallback){const e=()=>{this[Yg]&&(this[jg](),t.requestVideoFrameCallback(e))};t.requestVideoFrameCallback(e)}else{const t=()=>{this[Yg]&&(this[jg](),requestAnimationFrame(t))};requestAnimationFrame(t)}}else null!=(null==t?void 0:t.source.animation)&&t.source.animation.addEventListener("enterFrame",this[jg]);let s=At;if(this[qg])for(const t of this[qg]){switch(this[Xg]){case Kg.Base:t.map=n;break;case Kg.MetallicRoughness:s=pt,t.metalnessMap=n,t.roughnessMap=n;break;case Kg.Normal:s=pt,t.normalMap=n;break;case Kg.Occlusion:s=pt,t.aoMap=n;break;case Kg.Emissive:t.emissiveMap=n;break;case Kg.Clearcoat:t.clearcoatMap=n;break;case Kg.ClearcoatRoughness:t.clearcoatRoughnessMap=n;break;case Kg.ClearcoatNormal:t.clearcoatNormalMap=n;break;case Kg.SheenColor:t.sheenColorMap=n;break;case Kg.SheenRoughness:t.sheenRoughnessMap=n;break;case Kg.Transmission:t.transmissionMap=n;break;case Kg.Thickness:t.thicknessMap=n;break;case Kg.Specular:t.specularIntensityMap=n;break;case Kg.SpecularColor:t.specularColorMap=n;break;case Kg.Iridescence:t.iridescenceMap=n;break;case Kg.IridescenceThickness:t.iridescenceThicknessMap=n;break;case Kg.Anisotropy:t.anisotropyMap=n}t.needsUpdate=!0}n&&(n.colorSpace=s,n.rotation=this[Wg].rotation,n.repeat=this[Wg].scale,n.offset=this[Wg].offset),this[jg]()}}Gg=Vg,Hg=Wg,zg=Yg; +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const $g=Symbol("threeMaterial"),Zg=Symbol("threeMaterials"),tf=Symbol("baseColorTexture"),ef=Symbol("metallicRoughnessTexture");class nf extends mg{constructor(t,e){super(t,e);const{map:i,metalnessMap:n}=e.values().next().value;this[tf]=new Jg(t,Kg.Base,i,e),this[ef]=new Jg(t,Kg.MetallicRoughness,n,e)}get[Zg](){return this[Ag]}get[$g](){var t;return null===(t=this[Ag])||void 0===t?void 0:t.values().next().value}get baseColorFactor(){const t=[0,0,0,this[$g].opacity];return this[$g].color.toArray(t),t}get metallicFactor(){return this[$g].metalness}get roughnessFactor(){return this[$g].roughness}get baseColorTexture(){return this[tf]}get metallicRoughnessTexture(){return this[ef]}setBaseColorFactor(t){const e=new Ni;t instanceof Array?e.fromArray(t):e.set(t);for(const i of this[Zg])i.color.set(e),t instanceof Array?i.opacity=t[3]:(t=[0,0,0,i.opacity],e.toArray(t));this[pg]()}setMetallicFactor(t){for(const e of this[Zg])e.metalness=t;this[pg]()}setRoughnessFactor(t){for(const e of this[Zg])e.roughness=t;this[pg]()}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var rf,sf;const af=Symbol("pbrMetallicRoughness"),of=Symbol("normalTexture"),lf=Symbol("occlusionTexture"),cf=Symbol("emissiveTexture"),hf=Symbol("backingThreeMaterial"),uf=Symbol("applyAlphaCutoff"),df=Symbol("getAlphaMode"),Af=Symbol("lazyLoadGLTFInfo"),pf=Symbol("initialize"),mf=Symbol("getLoadedMaterial"),gf=Symbol("ensureMaterialIsLoaded"),ff=Symbol("gltfIndex"),vf=Symbol("setActive"),Ef=Symbol("variantIndices"),_f=Symbol("isActive"),yf=Symbol("variantSet"),xf=Symbol("modelVariants"),Sf=Symbol("name"),Cf=Symbol("pbrTextures");class If extends mg{constructor(t,e,i,n,r,s,a=void 0){super(t,r),this[rf]=new Set,this[sf]=new Map,this[ff]=e,this[_f]=i,this[xf]=n,this[Sf]=s,null==a?this[pf]():this[Af]=a}get[(rf=yf,sf=Cf,hf)](){return this[Ag].values().next().value}[pf](){const t=this[pg],e=this[Ag];this[af]=new nf(t,e);const{normalMap:i,aoMap:n,emissiveMap:r}=e.values().next().value;this[of]=new Jg(t,Kg.Normal,i,e),this[lf]=new Jg(t,Kg.Occlusion,n,e),this[cf]=new Jg(t,Kg.Emissive,r,e);const s=i=>{this[Cf].set(i,new Jg(t,i,null,e))};s(Kg.Clearcoat),s(Kg.ClearcoatRoughness),s(Kg.ClearcoatNormal),s(Kg.SheenColor),s(Kg.SheenRoughness),s(Kg.Transmission),s(Kg.Thickness),s(Kg.Specular),s(Kg.SpecularColor),s(Kg.Iridescence),s(Kg.IridescenceThickness),s(Kg.Anisotropy)}async[mf](){if(null!=this[Af]){const{set:t,material:e}=await this[Af].doLazyLoad();return this[Ag]=t,this[pf](),this[Af]=void 0,this.ensureLoaded=async()=>{},e}return this[Ag].values().next().value}colorFromRgb(t){const e=new Ni;return t instanceof Array?e.fromArray(t):e.set(t),e}[gf](){if(null!=this[Af])throw new Error(`Material "${this.name}" has not been loaded, call 'await\n myMaterial.ensureLoaded()' before using an unloaded material.`)}async ensureLoaded(){await this[mf]()}get isLoaded(){return null==this[Af]}get isActive(){return this[_f]}[vf](t){this[_f]=t}get name(){return this[Sf]||""}set name(t){if(this[Sf]=t,null!=this[Ag])for(const e of this[Ag])e.name=t}get pbrMetallicRoughness(){return this[gf](),this[af]}get normalTexture(){return this[gf](),this[of]}get occlusionTexture(){return this[gf](),this[lf]}get emissiveTexture(){return this[gf](),this[cf]}get emissiveFactor(){return this[gf](),this[hf].emissive.toArray()}get index(){return this[ff]}[Ef](){return this[yf]}hasVariant(t){const e=this[xf].get(t);return null!=e&&this[yf].has(e.index)}setEmissiveFactor(t){this[gf]();const e=this.colorFromRgb(t);for(const t of this[Ag])t.emissive.set(e);this[pg]()}[df](){return this[hf].transparent?"BLEND":this[hf].alphaTest>0?"MASK":"OPAQUE"}[uf](){this[gf]();for(const t of this[Ag])"MASK"===this[df]()?null==t.alphaTest&&(t.alphaTest=.5):t.alphaTest=void 0,t.needsUpdate=!0}setAlphaCutoff(t){this[gf]();for(const e of this[Ag])e.alphaTest=t,e.needsUpdate=!0;this[uf](),this[pg]()}getAlphaCutoff(){return this[gf](),this[hf].alphaTest}setDoubleSided(t){this[gf]();for(const e of this[Ag])e.side=t?c:o,e.needsUpdate=!0;this[pg]()}getDoubleSided(){return this[gf](),this[hf].side==c}setAlphaMode(t){this[gf]();const e=(t,e)=>{t.transparent=e,t.depthWrite=!e};for(const i of this[Ag])e(i,"BLEND"===t),i.alphaTest="MASK"===t?.5:void 0,i.needsUpdate=!0;this[pg]()}getAlphaMode(){return this[gf](),this[df]()}get emissiveStrength(){return this[gf](),this[hf].emissiveIntensity}setEmissiveStrength(t){this[gf]();for(const e of this[Ag])e.emissiveIntensity=t;this[pg]()}get clearcoatFactor(){return this[gf](),this[hf].clearcoat}get clearcoatRoughnessFactor(){return this[gf](),this[hf].clearcoatRoughness}get clearcoatTexture(){return this[gf](),this[Cf].get(Kg.Clearcoat)}get clearcoatRoughnessTexture(){return this[gf](),this[Cf].get(Kg.ClearcoatRoughness)}get clearcoatNormalTexture(){return this[gf](),this[Cf].get(Kg.ClearcoatNormal)}get clearcoatNormalScale(){return this[gf](),this[hf].clearcoatNormalScale.x}setClearcoatFactor(t){this[gf]();for(const e of this[Ag])e.clearcoat=t;this[pg]()}setClearcoatRoughnessFactor(t){this[gf]();for(const e of this[Ag])e.clearcoatRoughness=t;this[pg]()}setClearcoatNormalScale(t){this[gf]();for(const e of this[Ag])e.clearcoatNormalScale=new Ht(t,t);this[pg]()}get ior(){return this[gf](),this[hf].ior}setIor(t){this[gf]();for(const e of this[Ag])e.ior=t;this[pg]()}get sheenColorFactor(){return this[gf](),this[hf].sheenColor.toArray()}get sheenColorTexture(){return this[gf](),this[Cf].get(Kg.SheenColor)}get sheenRoughnessFactor(){return this[gf](),this[hf].sheenRoughness}get sheenRoughnessTexture(){return this[gf](),this[Cf].get(Kg.SheenRoughness)}setSheenColorFactor(t){this[gf]();const e=this.colorFromRgb(t);for(const t of this[Ag])t.sheenColor.set(e),t.sheen=1;this[pg]()}setSheenRoughnessFactor(t){this[gf]();for(const e of this[Ag])e.sheenRoughness=t,e.sheen=1;this[pg]()}get transmissionFactor(){return this[gf](),this[hf].transmission}get transmissionTexture(){return this[gf](),this[Cf].get(Kg.Transmission)}setTransmissionFactor(t){this[gf]();for(const e of this[Ag])e.transmission=t;this[pg]()}get thicknessFactor(){return this[gf](),this[hf].thickness}get thicknessTexture(){return this[gf](),this[Cf].get(Kg.Thickness)}get attenuationDistance(){return this[gf](),this[hf].attenuationDistance}get attenuationColor(){return this[gf](),this[hf].attenuationColor.toArray()}setThicknessFactor(t){this[gf]();for(const e of this[Ag])e.thickness=t;this[pg]()}setAttenuationDistance(t){this[gf]();for(const e of this[Ag])e.attenuationDistance=t;this[pg]()}setAttenuationColor(t){this[gf]();const e=this.colorFromRgb(t);for(const t of this[Ag])t.attenuationColor.set(e);this[pg]()}get specularFactor(){return this[gf](),this[hf].specularIntensity}get specularTexture(){return this[gf](),this[Cf].get(Kg.Specular)}get specularColorFactor(){return this[gf](),this[hf].specularColor.toArray()}get specularColorTexture(){return this[gf](),this[Cf].get(Kg.SheenColor)}setSpecularFactor(t){this[gf]();for(const e of this[Ag])e.specularIntensity=t;this[pg]()}setSpecularColorFactor(t){this[gf]();const e=this.colorFromRgb(t);for(const t of this[Ag])t.specularColor.set(e);this[pg]()}get iridescenceFactor(){return this[gf](),this[hf].iridescence}get iridescenceTexture(){return this[gf](),this[Cf].get(Kg.Iridescence)}get iridescenceIor(){return this[gf](),this[hf].iridescenceIOR}get iridescenceThicknessMinimum(){return this[gf](),this[hf].iridescenceThicknessRange[0]}get iridescenceThicknessMaximum(){return this[gf](),this[hf].iridescenceThicknessRange[1]}get iridescenceThicknessTexture(){return this[gf](),this[Cf].get(Kg.IridescenceThickness)}setIridescenceFactor(t){this[gf]();for(const e of this[Ag])e.iridescence=t;this[pg]()}setIridescenceIor(t){this[gf]();for(const e of this[Ag])e.iridescenceIOR=t;this[pg]()}setIridescenceThicknessMinimum(t){this[gf]();for(const e of this[Ag])e.iridescenceThicknessRange[0]=t;this[pg]()}setIridescenceThicknessMaximum(t){this[gf]();for(const e of this[Ag])e.iridescenceThicknessRange[1]=t;this[pg]()}get anisotropyStrength(){return this[gf](),this[hf].anisotropy}get anisotropyRotation(){return this[gf](),this[hf].anisotropyRotation}get anisotropyTexture(){return this[gf](),this[Cf].get(Kg.Anisotropy)}setAnisotropyStrength(t){this[gf]();for(const e of this[Ag])e.anisotropy=t;this[pg]()}setAnisotropyRotation(t){this[gf]();for(const e of this[Ag])e.anisotropyRotation=t;this[pg]()}}class wf{constructor(t){this.name="",this.children=new Array,this.name=t}}class Mf extends wf{constructor(t,e,i,n){super(t.name),this.materials=new Map,this.variantToMaterialMap=new Map,this.initialMaterialIdx=0,this.activeMaterialIdx=0,this.mesh=t;const{gltf:r,threeGLTF:s,threeObjectMap:a}=n;this.parser=s.parser,this.modelVariants=i,this.mesh.userData.variantData=i;const o=a.get(t.material);null!=o.materials?this.initialMaterialIdx=this.activeMaterialIdx=o.materials:console.error(`Primitive (${t.name}) missing initial material reference.`);const l=t.userData.associations||{};if(null==l.meshes)return void console.error("Mesh is missing primitive index association");const c=((r.meshes||[])[l.meshes].primitives||[])[l.primitives];if(null!=c){if(null!=c.material)this.materials.set(c.material,e[c.material]);else{const t=e.findIndex((t=>"Default"===t.name));t>=0?this.materials.set(t,e[t]):console.warn("gltfPrimitive has no material!")}if(c.extensions&&c.extensions.KHR_materials_variants){const t=c.extensions.KHR_materials_variants,n=s.parser.json.extensions.KHR_materials_variants.variants;for(const r of t.mappings){const t=e[r.material];this.materials.set(r.material,t);for(const e of r.variants){const{name:r}=n[e];this.variantToMaterialMap.set(e,t),t[Ef]().add(e),i.has(r)||i.set(r,{name:r,index:e})}}}}else console.error("Mesh primitive definition is missing.")}async setActiveMaterial(t){const e=this.materials.get(t);if(null!=e&&t!==this.activeMaterialIdx){this.mesh.material=await e[mf]();const{normalScale:i}=this.mesh.material;null!=i&&i.y*i.x<0!=(null==this.mesh.geometry.attributes.tangent)&&this.parser.assignFinalMaterial(this.mesh),this.activeMaterialIdx=t}return this.mesh.material}getActiveMaterial(){return this.materials.get(this.activeMaterialIdx)}getMaterial(t){return this.materials.get(t)}async enableVariant(t){if(null==t)return this.setActiveMaterial(this.initialMaterialIdx);if(null!=this.variantToMaterialMap&&this.modelVariants.has(t)){const e=this.modelVariants.get(t);return this.enableVariantHelper(e.index)}return null}async enableVariantHelper(t){if(null!=this.variantToMaterialMap&&null!=t){const e=this.variantToMaterialMap.get(t);if(null!=e)return this.setActiveMaterial(e.index)}return null}async instantiateVariants(){if(null!=this.variantToMaterialMap)for(const t of this.variantToMaterialMap.keys()){const e=this.mesh.userData.variantMaterials.get(t);if(null!=e.material)continue;const i=await this.enableVariantHelper(t);null!=i&&(e.material=i)}}get variantInfo(){return this.variantToMaterialMap}addVariant(t,e){if(!this.ensureVariantIsUnused(e))return!1;this.modelVariants.has(e)||this.modelVariants.set(e,{name:e,index:this.modelVariants.size});const i=this.modelVariants.get(e).index;return t[Ef]().add(i),this.variantToMaterialMap.set(i,t),this.materials.set(t.index,t),this.updateVariantUserData(i,t),!0}deleteVariant(t){if(this.variantInfo.has(t)){this.variantInfo.delete(t);const e=this.mesh.userData.variantMaterials;null!=e&&e.delete(t)}}updateVariantUserData(t,e){e[Ef]().add(t),this.mesh.userData.variantData=this.modelVariants,this.mesh.userData.variantMaterials=this.mesh.userData.variantMaterials||new Map;this.mesh.userData.variantMaterials.set(t,{material:e[Ag].values().next().value,gltfMaterialIndex:e.index})}ensureVariantIsUnused(t){const e=this.modelVariants.get(t);return null==e||!this.variantInfo.has(e.index)||(console.warn(`Primitive cannot add variant '${t}' for this material, it already exists.`),!1)}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var bf,Tf,Bf,Rf,Lf,Df;const Uf=Symbol("materials"),Pf=Symbol("hierarchy"),Nf=Symbol("roots"),Qf=Symbol("primitives"),Ff=Symbol("prepareVariantsForExport"),Of=Symbol("switchVariant"),kf=Symbol("materialFromPoint"),Gf=Symbol("nodeFromPoint"),Hf=Symbol("nodeFromIndex"),zf=Symbol("variantData"),Vf=Symbol("availableVariants"),Wf=Symbol("modelOnUpdate"),qf=Symbol("cloneMaterial");class Xf{constructor(t,e,i,n){this.gltf=t,this.gltfElementMap=e,this.mapKey=i,this.doLazyLoad=n}}class jf{constructor(t,e=(()=>{})){this[bf]=new Array,this[Tf]=new Array,this[Bf]=new Array,this[Rf]=new Array,this[Lf]=()=>{},this[Df]=new Map,this[Wf]=e;const{gltf:i,threeGLTF:n,gltfElementMap:r}=t;for(const[t,s]of i.materials.entries()){const a=r.get(s);if(null!=a)this[Uf].push(new If(e,t,!0,this[zf],a,s.name));else{const o=(i.materials||[])[t],l=t,c=async()=>{const t=await n.parser.getDependency("material",l),e=new Set;return r.set(o,e),e.add(t),{set:e,material:t}};this[Uf].push(new If(e,t,!1,this[zf],a,s.name,new Xf(i,r,o,c)))}}const s=new Map,a=new Array;for(const t of n.scene.children)a.push(t);for(;a.length>0;){const e=a.pop();let i=null;e instanceof _n?(i=new Mf(e,this.materials,this[zf],t),this[Qf].push(i)):i=new wf(e.name);const n=s.get(e);null!=n?n.children.push(i):this[Nf].push(i),this[Pf].push(i);for(const t of e.children)a.push(t),s.set(e,i)}}get materials(){return this[Uf]}[(bf=Uf,Tf=Pf,Bf=Nf,Rf=Qf,Lf=Wf,Df=zf,Vf)](){const t=Array.from(this[zf].values());return t.sort(((t,e)=>t.index-e.index)),t.map((t=>t.name))}getMaterialByName(t){const e=this[Uf].filter((e=>e.name===t));return e.length>0?e[0]:null}[Hf](t,e){const i=this[Pf].find((i=>{if(i instanceof Mf){const{meshes:n,primitives:r}=i.mesh.userData.associations;if(n==t&&r==e)return!0}return!1}));return null==i?null:i}[Gf](t){return this[Pf].find((e=>{if(e instanceof Mf){if(e.mesh===t.object)return!0}return!1}))}[kf](t){return this[Gf](t).getActiveMaterial()}async[Of](t){for(const e of this[Qf])await e.enableVariant(t);for(const t of this.materials)t[vf](!1);for(const t of this[Qf])this.materials[t.getActiveMaterial().index][vf](!0)}async[Ff](){const t=new Array;for(const e of this[Qf])t.push(e.instantiateVariants());await Promise.all(t)}[qf](t,e){const i=this.materials[t];i.isLoaded||console.error("Cloning an unloaded material,\n call 'material.ensureLoaded() before cloning the material.");const n=i[Ag],r=new Set;for(const[t,i]of n.entries()){const s=i.clone();s.name=e+(n.size>1?"_inst"+t:""),r.add(s)}const s=new If(this[Wf],this[Uf].length,!1,this[zf],r,e);return this[Uf].push(s),s}createMaterialInstanceForVariant(t,e,i,n=!0){let r=null;for(const n of this[Qf]){const s=this[zf].get(i);null!=s&&n.variantInfo.has(s.index)||null!=n.getMaterial(t)&&(this.hasVariant(i)||this.createVariant(i),null==r&&(r=this[qf](t,e)),n.addVariant(r,i))}if(n&&null!=r){r[vf](!0),this.materials[t][vf](!1);for(const t of this[Qf])t.enableVariant(i)}return r}createVariant(t){this[zf].has(t)?console.warn(`Variant '${t}'' already exists`):this[zf].set(t,{name:t,index:this[zf].size})}hasVariant(t){return this[zf].has(t)}setMaterialToVariant(t,e){if(null!=this[Vf]().find((t=>t===e)))if(t<0||t>=this.materials.length)console.error("setMaterialToVariant(): materialIndex is out of bounds.");else for(const i of this[Qf]){const n=i.getMaterial(t);null!=n&&i.addVariant(n,e)}else console.warn(`Can't add material to '${e}', the variant does not exist.'`)}updateVariantName(t,e){const i=this[zf].get(t);null!=i&&(i.name=e,this[zf].set(e,i),this[zf].delete(t))}deleteVariant(t){const e=this[zf].get(t);if(null!=e){for(const i of this.materials)i.hasVariant(t)&&i[yf].delete(e.index);for(const t of this[Qf])t.deleteVariant(e.index);this[zf].delete(t)}}} +/* @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var Yf=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const Kf=Symbol("currentGLTF"),Jf=Symbol("originalGltfJson"),$f=Symbol("model"),Zf=Symbol("getOnUpdateMethod"),tv=Symbol("buildTexture"),ev=new ge,iv=new ge,nv=new ge,rv=new zt,sv=new Ti,av=new me;class ov extends dd{constructor(t){super(document.createElement("div")),this.normal=new ge(0,1,0),this.initialized=!1,this.referenceCount=1,this.pivot=document.createElement("div"),this.slot=document.createElement("slot"),this.element.classList.add("annotation-wrapper"),this.slot.name=t.name,this.element.appendChild(this.pivot),this.pivot.appendChild(this.slot),this.updatePosition(t.position),this.updateNormal(t.normal),this.surface=t.surface}get facingCamera(){return!this.element.classList.contains("hide")}show(){this.facingCamera&&this.initialized||this.updateVisibility(!0)}hide(){!this.facingCamera&&this.initialized||this.updateVisibility(!1)}increment(){this.referenceCount++}decrement(){return this.referenceCount>0&&--this.referenceCount,0===this.referenceCount}updatePosition(t){if(null==t)return;const e=TA(t)[0].terms;for(let t=0;t<3;++t)this.position.setComponent(t,kA(e[t]).number);this.updateMatrixWorld()}updateNormal(t){if(null==t)return;const e=TA(t)[0].terms;for(let t=0;t<3;++t)this.normal.setComponent(t,e[t].number)}updateSurface(t){if(!t&&this.initialized)return;const{mesh:e,tri:i,bary:n}=this;if(null==e||null==i||null==n)return;e.getVertexPosition(i.x,ev),e.getVertexPosition(i.y,iv),e.getVertexPosition(i.z,nv),ev.toArray(rv.elements,0),iv.toArray(rv.elements,3),nv.toArray(rv.elements,6),this.position.copy(n).applyMatrix3(rv);const r=this.parent;r.worldToLocal(e.localToWorld(this.position)),sv.set(ev,iv,nv),sv.getNormal(this.normal).transformDirection(e.matrixWorld);const s=r.parent;av.setFromAxisAngle(ev.set(0,1,0),-s.yaw),this.normal.applyQuaternion(av)}orient(t){this.pivot.style.transform=`rotate(${t}rad)`}updateVisibility(t){t?this.element.classList.remove("hide"):this.element.classList.add("hide"),this.slot.assignedNodes().forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const i=e,n=i.dataset.visibilityAttribute;if(null!=n){const e=`data-${n}`;t?i.setAttribute(e,""):i.removeAttribute(e)}i.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:t}}))})),this.initialized=!0}}const lv={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float h;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"},cv={name:"VerticalBlurShader",uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform float v;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"};function hv(t,e,i){return(1-i)*t+i*e} +/* @license + * Copyright 2022 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class uv extends fi{constructor(t,e,i){super(),this.camera=new tr,this.renderTarget=null,this.renderTargetBlur=null,this.depthMaterial=new aa,this.horizontalBlurMaterial=new Mn(lv),this.verticalBlurMaterial=new Mn(cv),this.intensity=0,this.softness=1,this.boundingBox=new Ee,this.size=new ge,this.maxDimension=0,this.isAnimated=!1,this.needsUpdate=!1;const{camera:n}=this;n.rotation.x=Math.PI/2,n.left=-.5,n.right=.5,n.bottom=-.5,n.top=.5,this.add(n);const r=new zn,s=new Fi({opacity:1,transparent:!0,side:l});this.floor=new _n(r,s),this.floor.userData.shadow=!0,n.add(this.floor),this.blurPlane=new _n(r),this.blurPlane.visible=!1,n.add(this.blurPlane),t.target.add(this),this.depthMaterial.onBeforeCompile=function(t){t.fragmentShader=t.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * opacity );")},this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial.depthTest=!1,this.setScene(t,e,i)}setScene(t,e,i){const{boundingBox:n,size:r,rotation:s,position:a}=this;if(this.isAnimated=t.animationNames.length>0,this.boundingBox.copy(t.boundingBox),this.size.copy(t.size),this.maxDimension=Math.max(r.x,r.y,r.z)*(this.isAnimated?2:1),this.boundingBox.getCenter(a),"back"===i){const{min:t,max:e}=n;[t.y,t.z]=[t.z,t.y],[e.y,e.z]=[e.z,e.y],[r.y,r.z]=[r.z,r.y],s.x=Math.PI/2,s.y=Math.PI}else s.x=0,s.y=0;if(this.isAnimated){const t=n.min.y,e=n.max.y;r.y=this.maxDimension,n.expandByVector(r.subScalar(this.maxDimension).multiplyScalar(-.5)),n.min.y=t,n.max.y=e,r.set(this.maxDimension,e-t,this.maxDimension)}"bottom"===i?a.y=n.min.y:a.z=n.min.y,this.setSoftness(e)}setSoftness(t){this.softness=t;const{size:e,camera:i}=this,n=this.isAnimated?2:1,r=n*Math.pow(2,9-3*t);this.setMapSize(r);const s=e.y/2,a=e.y*n;i.near=0,i.far=hv(a,s,t),this.depthMaterial.opacity=1/t,i.updateProjectionMatrix(),this.setIntensity(this.intensity),this.setOffset(0)}setMapSize(t){const{size:e}=this;this.isAnimated&&(t*=2);const i=Math.floor(e.x>e.z?t:t*e.x/e.z),n=Math.floor(e.x>e.z?t*e.z/e.x:t),r=10+i,s=10+n;if(null==this.renderTarget||this.renderTarget.width===r&&this.renderTarget.height===s||(this.renderTarget.dispose(),this.renderTarget=null,this.renderTargetBlur.dispose(),this.renderTargetBlur=null),null==this.renderTarget){const t={format:k};this.renderTarget=new de(r,s,t),this.renderTargetBlur=new de(r,s,t),this.floor.material.map=this.renderTarget.texture}this.camera.scale.set(e.x*(1+10/i),e.z*(1+10/n),1),this.needsUpdate=!0}setIntensity(t){this.intensity=t,t>0?(this.visible=!0,this.floor.visible=!0,this.floor.material.opacity=t*hv(.3,1,this.softness*this.softness)):(this.visible=!1,this.floor.visible=!1)}getIntensity(){return this.intensity}setOffset(t){this.floor.position.z=-t+.001*this.maxDimension}render(t,e){e.overrideMaterial=this.depthMaterial;const i=t.getClearAlpha();t.setClearAlpha(0),this.floor.visible=!1;const n=t.xr.enabled;t.xr.enabled=!1;const r=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.render(e,this.camera),e.overrideMaterial=null,this.floor.visible=!0,this.blurShadow(t),t.xr.enabled=n,t.setRenderTarget(r),t.setClearAlpha(i)}blurShadow(t){const{camera:e,horizontalBlurMaterial:i,verticalBlurMaterial:n,renderTarget:r,renderTargetBlur:s,blurPlane:a}=this;a.visible=!0,a.material=i,i.uniforms.h.value=1/this.renderTarget.width,i.uniforms.tDiffuse.value=this.renderTarget.texture,t.setRenderTarget(s),t.render(a,e),a.material=n,n.uniforms.v.value=1/this.renderTarget.height,n.uniforms.tDiffuse.value=this.renderTargetBlur.texture,t.setRenderTarget(r),t.render(a,e),a.visible=!1}dispose(){null!=this.renderTarget&&this.renderTarget.dispose(),null!=this.renderTargetBlur&&this.renderTargetBlur.dispose(),this.depthMaterial.dispose(),this.horizontalBlurMaterial.dispose(),this.verticalBlurMaterial.dispose(),this.floor.material.dispose(),this.floor.geometry.dispose(),this.blurPlane.geometry.dispose(),this.removeFromParent()}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */const dv=new ge,Av=new ge,pv=new ge,mv=new class{constructor(t,e,i=0,n=1/0){this.ray=new We(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new ni,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}intersectObject(t,e=!0,i=[]){return wl(t,this,i,e),i.sort(Il),i}intersectObjects(t,e=!0,i=[]){for(let n=0,r=t.length;n{})){if(!t||t===this.url)return void e(1);if(this.reset(),this.url=t,null!=this.externalRenderer){const t=await this.externalRenderer.load(e);return this.boundingSphere.radius=t.framedRadius,void(this.idealAspect=t.fieldOfViewAspect)}let i;null!=this.cancelPendingSourceChange&&(this.cancelPendingSourceChange(),this.cancelPendingSourceChange=null);try{i=await new Promise((async(i,n)=>{this.cancelPendingSourceChange=()=>n();try{i(await this.element[cE].loader.load(t,this.element,e))}catch(t){n(t)}}))}catch(t){if(null==t)return;throw t}this.cancelPendingSourceChange=null,this.reset(),this.url=t,this._currentGLTF=i,null!=i&&(this._model=i.scene,this.target.add(i.scene));const{animations:n}=i,r=new Map,s=[];for(const t of n)r.set(t.name,t),s.push(t.name);this.animations=n,this.animationsByName=r,this.animationNames=s,await this.setupScene()}async setupScene(){this.applyTransform(),this.updateBoundingBox(),await this.updateFraming(),this.updateShadow(),this.setShadowIntensity(this.shadowIntensity)}reset(){this.url=null,this.renderCount=0,this.queueRender(),null!=this.shadow&&this.shadow.setIntensity(0),this.bakedShadows.clear();const{_model:t}=this;null!=t&&(t.removeFromParent(),this._model=null);const e=this._currentGLTF;null!=e&&(e.dispose(),this._currentGLTF=null),null!=this.currentAnimationAction&&(this.currentAnimationAction.stop(),this.currentAnimationAction=null),this.mixer.stopAllAction(),this.mixer.uncacheRoot(this)}dispose(){this.reset(),null!=this.shadow&&(this.shadow.dispose(),this.shadow=null),this.element[Kf]=null,this.element[Jf]=null,this.element[$f]=null}get currentGLTF(){return this._currentGLTF}setSize(t,e){if(this.width!==t||this.height!==e){if(this.width=Math.max(t,1),this.height=Math.max(e,1),this.annotationRenderer.setSize(t,e),this.aspect=this.width/this.height,null!=this.externalRenderer){const i=dh();this.externalRenderer.resize(t*i,e*i)}this.queueRender()}}markBakedShadow(t){t.userData.shadow=!0,this.bakedShadows.add(t)}unmarkBakedShadow(t){t.userData.shadow=!1,t.visible=!0,this.bakedShadows.delete(t),this.boundingBox.expandByObject(t)}findBakedShadows(t){const e=new Ee;t.traverse((t=>{const i=t;if(!i.material)return;if(!i.material.transparent)return;e.setFromObject(i);const n=e.getSize(gv),r=Math.min(n.x,n.y,n.z);Math.max(n.x,n.y,n.z)<100*r||this.markBakedShadow(i)}))}checkBakedShadows(){const{min:t,max:e}=this.boundingBox,i=new Ee;this.boundingBox.getSize(this.size);for(const n of this.bakedShadows)i.setFromObject(n),i.min.y=e.x&&i.min.z<=t.z&&i.max.z>=e.z||i.min.z=e.x&&i.min.y<=t.y&&i.max.y>=e.y||this.unmarkBakedShadow(n)}applyTransform(){const{model:t}=this;if(null==t)return;const e=TA(this.element.orientation)[0].terms,i=kA(e[0]).number,n=kA(e[1]).number,r=kA(e[2]).number;t.quaternion.setFromEuler(new ii(n,r,i,"YXZ"));const s=TA(this.element.scale)[0].terms;t.scale.set(s[0].number,s[1].number,s[2].number)}updateBoundingBox(){const{model:t}=this;if(null==t)return;this.target.remove(t),this.findBakedShadows(t);const e=(t,e)=>t.expandByPoint(e);this.setBakedShadowVisibility(!1),this.boundingBox=Ed(t,e,new Ee),this.boundingBox.isEmpty()&&(this.setBakedShadowVisibility(!0),this.bakedShadows.forEach((t=>this.unmarkBakedShadow(t))),this.boundingBox=Ed(t,e,new Ee)),this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size),this.target.add(t)}async updateFraming(){const{model:t}=this;if(null==t)return;this.target.remove(t),this.setBakedShadowVisibility(!1);const{center:e}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,e.copy(this.getTarget());this.boundingSphere.radius=Math.sqrt(Ed(t,((t,i)=>Math.max(t,e.distanceToSquared(i))),0));this.idealAspect=Ed(t,((t,i)=>{i.sub(e);const n=Math.sqrt(i.x*i.x+i.z*i.z);return Math.max(t,n/(this.idealCameraDistance()-Math.abs(i.y)))}),0)/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility(),this.target.add(t)}setBakedShadowVisibility(t=this.shadowIntensity<=0){for(const e of this.bakedShadows)e.visible=t}idealCameraDistance(){const t=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(t)}adjustedFoV(t){const e=Math.tan(t/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(e)*180/Math.PI}getNDC(t,e){if(null!=this.xrCamera)fv.set(t/window.screen.width,e/window.screen.height);else{const i=this.element.getBoundingClientRect();fv.set((t-i.x)/this.width,(e-i.y)/this.height)}return fv.multiplyScalar(2).subScalar(1),fv.y*=-1,fv}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(t,e){this.element[cE].arRenderer.presentedScene!==this&&(this.environment=t,this.background=e,this.queueRender())}setTarget(t,e,i){this.goalTarget.set(-t,-e,-i)}setTargetDamperDecayTime(t){this.targetDamperX.setDecayTime(t),this.targetDamperY.setDecayTime(t),this.targetDamperZ.setDecayTime(t)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget(1e4)}updateTarget(t){const e=this.goalTarget,i=this.target.position;if(e.equals(i))return!1;{const n=this.boundingSphere.radius/10;let{x:r,y:s,z:a}=i;return r=this.targetDamperX.update(r,e.x,t,n),s=this.targetDamperY.update(s,e.y,t,n),a=this.targetDamperZ.update(a,e.z,t,n),this.target.position.set(r,s,a),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(t,e){const{x:i,z:n}=this.position;this.yaw=Math.atan2(t-i,e-n)}get model(){return this._model}set yaw(t){this.rotation.y=t,this.queueRender()}get yaw(){return this.rotation.y}set animationTime(t){this.mixer.setTime(t),this.queueShadowRender()}get animationTime(){if(null!=this.currentAnimationAction){const t=Math.max(this.currentAnimationAction._loopCount,0);return this.currentAnimationAction.loop===nt&&1==(1&t)?this.duration-this.currentAnimationAction.time:this.currentAnimationAction.time}return 0}set animationTimeScale(t){this.mixer.timeScale=t}get animationTimeScale(){return this.mixer.timeScale}get duration(){return null!=this.currentAnimationAction&&this.currentAnimationAction.getClip()?this.currentAnimationAction.getClip().duration:0}get hasActiveAnimation(){return null!=this.currentAnimationAction}playAnimation(t=null,e=0,i=2201,n=1/0){if(null==this._currentGLTF)return;const{animations:r}=this;if(null==r||0===r.length)return;let s=null;if(null!=t&&(s=this.animationsByName.get(t),null==s)){const e=parseInt(t);!isNaN(e)&&e>=0&&e0&&this.animationTime==this.duration&&(this.animationTime=0)),r.setLoop(i,n),r.enabled=!0,r.clampWhenFinished=!0,r.play()}catch(t){console.error(t)}}stopAnimation(){this.currentAnimationAction=null,this.mixer.stopAllAction()}updateAnimation(t){this.mixer.update(t),this.queueShadowRender()}subscribeMixerEvent(t,e){this.mixer.addEventListener(t,e)}updateShadow(){const t=this.shadow;if(null!=t){const e="wall"===this.element.arPlacement?"back":"bottom";t.setScene(this,this.shadowSoftness,e),t.needsUpdate=!0}}renderShadow(t){const e=this.shadow;null!=e&&1==e.needsUpdate&&(e.render(t,this),e.needsUpdate=!1)}queueShadowRender(){null!=this.shadow&&(this.shadow.needsUpdate=!0)}setShadowIntensity(t){if(this.shadowIntensity=t,null!=this._currentGLTF&&(this.setBakedShadowVisibility(),!(t<=0&&null==this.shadow))){if(null==this.shadow){const t="wall"===this.element.arPlacement?"back":"bottom";this.shadow=new uv(this,this.shadowSoftness,t)}this.shadow.setIntensity(t)}}setShadowSoftness(t){this.shadowSoftness=t;const e=this.shadow;null!=e&&e.setSoftness(t)}setShadowOffset(t){const e=this.shadow;null!=e&&e.setOffset(t)}hitFromPoint(t,e=this){mv.setFromCamera(t,this.getCamera());return mv.intersectObject(e,!0).find((t=>t.object.visible&&!t.object.userData.shadow))}positionAndNormalFromPoint(t,e=this){var i;const n=this.hitFromPoint(t,e);if(null==n)return null;return{position:n.point,normal:null!=n.face?n.face.normal.clone().applyNormalMatrix((new zt).getNormalMatrix(n.object.matrixWorld)):mv.ray.direction.clone().multiplyScalar(-1),uv:null!==(i=n.uv)&&void 0!==i?i:null}}surfaceFromPoint(t,e=this){const i=this.element.model;if(null==i)return null;const n=this.hitFromPoint(t,e);if(null==n||null==n.face)return null;const r=i[Gf](n),{meshes:s,primitives:a}=r.mesh.userData.associations,o=new ge,l=new ge,c=new ge,{a:h,b:u,c:d}=n.face,A=n.object;A.getVertexPosition(h,o),A.getVertexPosition(u,l),A.getVertexPosition(d,c);const p=new Ti(o,l,c),m=new ge;return p.getBarycoord(A.worldToLocal(n.point),m),`${s} ${a} ${h} ${u} ${d} ${m.x.toFixed(3)} ${m.y.toFixed(3)} ${m.z.toFixed(3)}`}addHotspot(t){this.target.add(t),this.annotationRenderer.domElement.appendChild(t.element)}removeHotspot(t){this.target.remove(t)}forHotspots(t){const{children:e}=this.target;for(let i=0,n=e.length;i=r||n.y>=r||n.z>=r)return void console.warn(t.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");const s=new ge(e[5].number,e[6].number,e[7].number);t.mesh=i.mesh,t.tri=n,t.bary=s}}updateSurfaceHotspots(){const t=!this.element.paused;this.forHotspots((e=>{this.initializeSurface(e),e.updateSurface(t)}))}updateHotspotsVisibility(t){this.forHotspots((e=>{dv.copy(t),Av.setFromMatrixPosition(e.matrixWorld),dv.sub(Av),pv.copy(e.normal).transformDirection(this.target.matrixWorld),dv.dot(pv)<0?e.hide():e.show()}))}orientHotspots(t){this.forHotspots((e=>{e.orient(t)}))}setHotspotsVisibility(t){this.forHotspots((e=>{e.visible=t}))}updateSchema(t){var e;const{schemaElement:i,element:n}=this,{alt:r,poster:s,iosSrc:a}=n;if(null!=t){const n=[{"@type":"MediaObject",contentUrl:t,encodingFormat:"gltf"===(null===(e=t.split(".").pop())||void 0===e?void 0:e.toLowerCase())?"model/gltf+json":"model/gltf-binary"}];a&&n.push({"@type":"MediaObject",contentUrl:a,encodingFormat:"model/vnd.usdz+zip"});const o={"@context":"http://schema.org/","@type":"3DModel",image:null!=s?s:void 0,name:null!=r?r:void 0,encoding:n};i.textContent=JSON.stringify(o),document.head.appendChild(i)}else null!=i.parentElement&&i.parentElement.removeChild(i)}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */class Ev extends EventTarget{constructor(){super(...arguments),this.ongoingActivities=new Set,this.totalProgress=0}get ongoingActivityCount(){return this.ongoingActivities.size}beginActivity(){const t={progress:0,completed:!1};return this.ongoingActivities.add(t),1===this.ongoingActivityCount&&this.announceTotalProgress(t,0),e=>{let i;return i=Math.max(uh(e,0,1),t.progress),i!==t.progress&&this.announceTotalProgress(t,i),t.progress}}announceTotalProgress(t,e){let i=0,n=0;1==e&&(t.completed=!0);for(const t of this.ongoingActivities){const{progress:e}=t;i+=1-e,!0===t.completed&&n++}const r=t.progress;t.progress=e,this.totalProgress+=(e-r)*(1-this.totalProgress)/i;const s=n===this.ongoingActivityCount?1:this.totalProgress;this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:s}})),n===this.ongoingActivityCount&&(this.totalProgress=0,this.ongoingActivities.clear())}} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */var _v,yv,xv,Sv,Cv,Iv,wv,Mv,bv,Tv,Bv,Rv,Lv,Dv=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const Uv=document.createElement("canvas"),Pv=Symbol("fallbackResizeHandler"),Nv=Symbol("defaultAriaLabel"),Qv=Symbol("resizeObserver"),Fv=Symbol("clearModelTimeout"),Ov=Symbol("onContextLost"),kv=Symbol("loaded"),Gv=Symbol("status"),Hv=Symbol("onFocus"),zv=Symbol("onBlur"),Vv=Symbol("updateSize"),Wv=Symbol("intersectionObserver"),qv=Symbol("isElementInViewport"),Xv=Symbol("announceModelVisibility"),jv=Symbol("ariaLabel"),Yv=Symbol("altDefaulted"),Kv=Symbol("statusElement"),Jv=Symbol("updateStatus"),$v=Symbol("loadedTime"),Zv=Symbol("updateSource"),tE=Symbol("markLoaded"),eE=Symbol("container"),iE=Symbol("input"),nE=Symbol("canvas"),rE=Symbol("scene"),sE=Symbol("needsRender"),aE=Symbol("tick"),oE=Symbol("onModelLoad"),lE=Symbol("onResize"),cE=Symbol("renderer"),hE=Symbol("progressTracker"),uE=Symbol("getLoaded"),dE=Symbol("getModelIsVisible"),AE=Symbol("shouldAttemptPreload"),pE=t=>({x:t.x,y:t.y,z:t.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),mE=t=>({u:t.x,v:t.y,toString(){return`${this.u} ${this.v}`}});class gE extends Vc{constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[_v]=!1,this[yv]=!1,this[xv]=0,this[Sv]="",this[Cv]=null,this[Iv]=hh((()=>{const t=this.getBoundingClientRect();this[Vv](t)}),50),this[wv]=hh((t=>{const e=this.modelIsVisible;e!==t&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:e}}))}),0),this[Mv]=null,this[bv]=null,this[Tv]=new Ev,this[Bv]=()=>{this[Kv].textContent=this[Gv]},this[Rv]=()=>{this[Kv].textContent=""},this[Lv]=t=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:t.sourceEvent}}))},this.attachShadow({mode:"open"});const t=this.shadowRoot;let e,i;if((t=>{bc(Eh,t)})(t),this[eE]=t.querySelector(".container"),this[iE]=t.querySelector(".userInput"),this[nE]=t.querySelector("canvas"),this[Kv]=t.querySelector("#status"),this[Nv]=this[iE].getAttribute("aria-label"),this.isConnected){const t=this.getBoundingClientRect();e=t.width,i=t.height}else e=300,i=150;this[rE]=new vv({canvas:this[nE],element:this,width:e,height:i}),Promise.resolve().then((()=>{this[Vv](this.getBoundingClientRect())})),Jc&&(this[Qv]=new ResizeObserver((t=>{if(!this[cE].isPresenting)for(let e of t)e.target===this&&this[Vv](e.contentRect)}))),$c?this[Wv]=new IntersectionObserver((t=>{for(let e of t)if(e.target===this){const t=this.modelIsVisible;this[qv]=e.isIntersecting,this[Xv](t),this[qv]&&!this.loaded&&this[Zv]()}}),{root:null,rootMargin:"0px",threshold:1e-5}):this[qv]=!0}static get is(){return"model-viewer"}static set modelCacheSize(t){ud[cd].evictionThreshold=t}static get modelCacheSize(){return ud[cd].evictionThreshold}static set minimumRenderScale(t){t>1&&console.warn(" minimumRenderScale has been clamped to a maximum value of 1."),t<=0&&console.warn(" minimumRenderScale has been clamped to a minimum value of 0.25."),dg.singleton.minScale=t}static get minimumRenderScale(){return dg.singleton.minScale}get loaded(){return this[uE]()}get[(_v=qv,yv=kv,xv=$v,Sv=Gv,Cv=Fv,Iv=Pv,wv=Xv,Mv=Qv,bv=Wv,Tv=hE,cE)](){return dg.singleton}get modelIsVisible(){return this[dE]()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),Jc?this[Qv].observe(this):self.addEventListener("resize",this[Pv]),$c&&this[Wv].observe(this),this.addEventListener("focus",this[Hv]),this.addEventListener("blur",this[zv]);const t=this[cE];t.addEventListener("contextlost",this[Ov]),t.registerScene(this[rE]),null!=this[Fv]&&(self.clearTimeout(this[Fv]),this[Fv]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),Jc?this[Qv].unobserve(this):self.removeEventListener("resize",this[Pv]),$c&&this[Wv].unobserve(this),this.removeEventListener("focus",this[Hv]),this.removeEventListener("blur",this[zv]);const t=this[cE];t.removeEventListener("contextlost",this[Ov]),t.unregisterScene(this[rE]),this[Fv]=self.setTimeout((()=>{this[rE].dispose(),this[Fv]=null}),10)}updated(t){super.updated(t),t.has("src")&&(null==this.src?(this[kv]=!1,this[$v]=0,this[rE].reset()):this.src!==this[rE].url&&(this[kv]=!1,this[$v]=0,this[Zv]())),t.has("alt")&&this[iE].setAttribute("aria-label",this[jv]),t.has("withCredentials")&&(ud.withCredentials=this.withCredentials,this[cE].textureUtils.withCredentials=this.withCredentials),t.has("generateSchema")&&(this.generateSchema?this[rE].updateSchema(this.src):this[rE].updateSchema(null))}toDataURL(t,e){return this[cE].displayCanvas(this[rE]).toDataURL(t,e)}async toBlob(t){const e=t?t.mimeType:void 0,i=t?t.qualityArgument:void 0,n=t?t.idealAspect:void 0,{width:r,height:s,idealAspect:a,aspect:o}=this[rE],{dpr:l,scaleFactor:c}=this[cE];let h=r*c*l,u=s*c*l,d=0,A=0;if(!0===n)if(a>o){const t=u;u=Math.round(h/a),A=(t-u)/2}else{const t=h;h=Math.round(u*a),d=(t-h)/2}Uv.width=h,Uv.height=u;try{return new Promise((async(t,n)=>{Uv.getContext("2d").drawImage(this[cE].displayCanvas(this[rE]),d,A,h,u,0,0,h,u),Uv.toBlob((e=>{if(!e)return n(new Error("Unable to retrieve canvas blob"));t(e)}),e,i)}))}finally{this[Vv]({width:r,height:s})}}registerEffectComposer(t){t.setRenderer(this[cE].threeRenderer),t.setMainCamera(this[rE].getCamera()),t.setMainScene(this[rE]),this[rE].effectRenderer=t}unregisterEffectComposer(){this[rE].effectRenderer=null}registerRenderer(t){this[rE].externalRenderer=t}unregisterRenderer(){this[rE].externalRenderer=null}get[jv](){return this[Yv]}get[Yv](){return null==this.alt||"null"===this.alt?this[Nv]:this.alt}[uE](){return this[kv]}[dE](){return this.loaded&&this[qv]}[AE](){return!!this.src&&this[qv]}[Vv]({width:t,height:e}){0!==t&&0!==e&&(this[eE].style.width=`${t}px`,this[eE].style.height=`${e}px`,this[lE]({width:t,height:e}))}[aE](t,e){var i;null===(i=this[rE].effectRenderer)||void 0===i||i.beforeRender(t,e)}[tE](){this[kv]||(this[kv]=!0,this[$v]=performance.now())}[sE](){this[rE].queueRender()}[oE](){}[Jv](t){this[Gv]=t;const e=this.getRootNode();null!=e&&e.activeElement===this&&this[Kv].textContent!=t&&(this[Kv].textContent=t)}[(Bv=Hv,Rv=zv,lE)](t){this[rE].setSize(t.width,t.height)}async[(Lv=Ov,Zv)](){const t=this[rE];if(this.loaded||!this[AE]()||this.src===t.url)return;this.generateSchema&&t.updateSchema(this.src),this[Jv]("Loading"),t.stopAnimation();const e=this[hE].beginActivity(),i=this.src;try{const n=t.setSource(i,(t=>e(.95*uh(t,0,1)))),r=this[fh]();await Promise.all([n,r]),this[tE](),this[oE](),this.updateComplete.then((()=>{this.dispatchEvent(new CustomEvent("before-render"))})),await new Promise((t=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.dispatchEvent(new CustomEvent("load",{detail:{url:i}})),t()}))}))}))}catch(t){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:t}}))}finally{e(1)}}}Dv([e({type:String})],gE.prototype,"alt",void 0),Dv([e({type:String})],gE.prototype,"src",void 0),Dv([e({type:Boolean,attribute:"with-credentials"})],gE.prototype,"withCredentials",void 0),Dv([e({type:Boolean,attribute:"generate-schema"})],gE.prototype,"generateSchema",void 0); +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var fE=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const vE=Symbol("changeAnimation"),EE=Symbol("paused"),_E={repetitions:1/0,pingpong:!1},yE=Symbol("hotspotMap"),xE=Symbol("mutationCallback"),SE=Symbol("observer"),CE=Symbol("addHotspot"),IE=Symbol("removeHotspot"),wE=new qe; +/*! +fflate - fast JavaScript compression/decompression + +Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE +version 0.6.9 +*/ +var ME=function(t){return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};try{URL.revokeObjectURL(ME(""))}catch(Nc){ME=function(t){return"data:application/javascript;charset=UTF-8,"+encodeURI(t)}}var bE=Uint8Array,TE=Uint16Array,BE=Uint32Array,RE=new bE([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),LE=new bE([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),DE=new bE([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),UE=function(t,e){for(var i=new TE(31),n=0;n<31;++n)i[n]=e+=1<>>1|(21845&kE)<<1;GE=(61680&(GE=(52428&GE)>>>2|(13107&GE)<<2))>>>4|(3855&GE)<<4,OE[kE]=((65280&GE)>>>8|(255&GE)<<8)>>>1}var HE=function(t,e,i){for(var n=t.length,r=0,s=new TE(e);r>>l]=c}else for(a=new TE(n),r=0;r>>15-t[r]);return a},zE=new bE(288);for(kE=0;kE<144;++kE)zE[kE]=8;for(kE=144;kE<256;++kE)zE[kE]=9;for(kE=256;kE<280;++kE)zE[kE]=7;for(kE=280;kE<288;++kE)zE[kE]=8;var VE=new bE(32);for(kE=0;kE<32;++kE)VE[kE]=5;var WE=HE(zE,9,0),qE=HE(VE,5,0),XE=function(t){return(t/8|0)+(7&t&&1)},jE=function(t,e,i){(null==e||e<0)&&(e=0),(null==i||i>t.length)&&(i=t.length);var n=new(t instanceof TE?TE:t instanceof BE?BE:bE)(i-e);return n.set(t.subarray(e,i)),n},YE=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>>8},KE=function(t,e,i){i<<=7&e;var n=e/8|0;t[n]|=i,t[n+1]|=i>>>8,t[n+2]|=i>>>16},JE=function(t,e){for(var i=[],n=0;nd&&(d=s[n].s);var A=new TE(d+1),p=$E(i[h-1],A,0);if(p>e){n=0;var m=0,g=p-e,f=1<e))break;m+=f-(1<>>=g;m>0;){var E=s[n].s;A[E]=0&&m;--n){var _=s[n].s;A[_]==e&&(--A[_],++m)}p=e}return[new bE(A),p]},$E=function(t,e,i){return-1==t.s?Math.max($E(t.l,e,i+1),$E(t.r,e,i+1)):e[t.s]=i},ZE=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new TE(++e),n=0,r=t[0],s=1,a=function(t){i[n++]=t},o=1;o<=e;++o)if(t[o]==r&&o!=e)++s;else{if(!r&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(r),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(r);s=1,r=t[o]}return[i.subarray(0,n),e]},t_=function(t,e){for(var i=0,n=0;n>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s4&&!w[DE[b-1]];--b);var T,B,R,L,D=c+5<<3,U=t_(r,zE)+t_(s,VE)+a,P=t_(r,d)+t_(s,m)+a+14+3*b+t_(S,w)+(2*S[16]+3*S[17]+7*S[18]);if(D<=U&&D<=P)return e_(e,h,t.subarray(l,l+c));if(YE(e,h,1+(P15&&(YE(e,h,O[C]>>>5&127),h+=O[C]>>>12)}}}else T=WE,B=zE,R=qE,L=VE;for(C=0;C255){k=n[C]>>>18&31;KE(e,h,T[k+257]),h+=B[k+257],k>7&&(YE(e,h,n[C]>>>23&31),h+=RE[k]);var G=31&n[C];KE(e,h,R[G]),h+=L[G],G>3&&(KE(e,h,n[C]>>>5&8191),h+=LE[G])}else KE(e,h,T[n[C]]),h+=B[n[C]];return KE(e,h,T[256]),h+B[256]},n_=new BE([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),r_=new bE(0),s_=function(){for(var t=new BE(256),e=0;e<256;++e){for(var i=e,n=9;--n;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),a_=function(){var t=-1;return{p:function(e){for(var i=t,n=0;n>>8;t=i},d:function(){return~t}}},o_=function(t,e,i,n,r){return function(t,e,i,n,r,s){var a=t.length,o=new bE(n+a+5*(1+Math.ceil(a/7e3))+r),l=o.subarray(n,o.length-r),c=0;if(!e||a<8)for(var h=0;h<=a;h+=65535){var u=h+65535;u>>13,p=8191&d,m=(1<7e3||w>24576)&&L>423){c=i_(t,l,0,y,x,S,I,w,b,h-b,c),w=C=I=0,b=h;for(var D=0;D<286;++D)x[D]=0;for(D=0;D<30;++D)S[D]=0}var U=2,P=0,N=p,Q=B-R&32767;if(L>2&&T==_(h-Q))for(var F=Math.min(A,L)-1,O=Math.min(32767,h),k=Math.min(258,L);Q<=O&&--N&&B!=R;){if(t[h+U]==t[h+U-Q]){for(var G=0;GU){if(U=G,P=Q,G>F)break;var H=Math.min(Q,G-2),z=0;for(D=0;Dz&&(z=W,R=V)}}}Q+=(B=R)-(R=g[B])+32768&32767}if(P){y[w++]=268435456|QE[U]<<18|FE[P];var q=31&QE[U],X=31&FE[P];I+=RE[q]+LE[X],++x[257+q],++S[X],M=h+U,++C}else y[w++]=t[h],++x[t[h]]}}c=i_(t,l,s,y,x,S,I,w,b,h-b,c),!s&&7&c&&(c=e_(l,c+1,r_))}return jE(o,0,n+XE(c)+r)}(t,null==e.level?6:e.level,null==e.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,i,n,!r)},l_=function(t,e){var i={};for(var n in t)i[n]=t[n];for(var n in e)i[n]=e[n];return i},c_=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function h_(t,e){return o_(t,e||{},0,0)}var u_=function(t,e,i,n){for(var r in t){var s=t[r],a=e+r;s instanceof bE?i[a]=[s,n]:Array.isArray(s)?i[a]=[s[0],l_(n,s[1])]:u_(s,a+"/",i,n)}},d_="undefined"!=typeof TextEncoder&&new TextEncoder,A_="undefined"!=typeof TextDecoder&&new TextDecoder;try{A_.decode(r_,{stream:!0}),1}catch(Nc){}function p_(t,e){if(e){for(var i=new bE(t.length),n=0;n>1)),a=0,o=function(t){s[a++]=t};for(n=0;ns.length){var l=new bE(a+8+(r-n<<1));l.set(s),s=l}var c=t.charCodeAt(n);c<128||e?o(c):c<2048?(o(192|c>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++n))>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|63&c)):(o(224|c>>12),o(128|c>>6&63),o(128|63&c))}return jE(s,0,a)}var m_=function(t){var e=0;if(t)for(var i in t){var n=t[i].length;if(n>65535)throw"extra field too long";e+=n+4}return e},g_=function(t,e,i,n,r,s,a,o){var l=n.length,c=i.extra,h=o&&o.length,u=m_(c);c_(t,e,null!=a?33639248:67324752),e+=4,null!=a&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(null==s&&8),t[e++]=r&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var d=new Date(null==i.mtime?Date.now():i.mtime),A=d.getFullYear()-1980;if(A<0||A>119)throw"date not in range 1980-2099";if(c_(t,e,A<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),e+=4,null!=s&&(c_(t,e,i.crc),c_(t,e+4,s),c_(t,e+8,i.size)),c_(t,e+12,l),c_(t,e+14,u),e+=16,null!=a&&(c_(t,e,h),c_(t,e+6,i.attrs),c_(t,e+10,a),e+=14),t.set(n,e),e+=l,u)for(var p in c){var m=c[p],g=m.length;c_(t,e,+p),c_(t,e+2,g),t.set(m,e+4),e+=4+g}return h&&(t.set(o,e),e+=h),e};function f_(t,e){e||(e={});var i={},n=[];u_(t,"",i,e);var r=0,s=0;for(var a in i){var o=i[a],l=o[0],c=o[1],h=0==c.level?0:8,u=(S=p_(a)).length,d=c.comment,A=d&&p_(d),p=A&&A.length,m=m_(c.extra);if(u>65535)throw"filename too long";var g=h?h_(l,c):l,f=g.length,v=a_();v.p(l),n.push(l_(c,{size:l.length,crc:v.d(),c:g,f:S,m:A,u:u!=a.length||A&&d.length!=p,o:r,compression:h})),r+=30+u+m+f,s+=76+2*(u+m)+(p||0)+f}for(var E=new bE(s+22),_=r,y=s-r,x=0;x{if(t.isMesh){const e=t.geometry,n=t.material;if(n.isMeshStandardMaterial){const a="geometries/Geometry_"+e.id+".usda";if(!(a in i)){const t=function(t){const e=function(t){const e="Geometry",i=t.attributes,n=i.position.count;return`\n\tdef Mesh "${e}"\n\t{\n\t\tint[] faceVertexCounts = [${function(t){const e=null!==t.index?t.index.count:t.attributes.position.count;return Array(e/3).fill(3).join(", ")}(t)}]\n\t\tint[] faceVertexIndices = [${function(t){const e=t.index,i=[];if(null!==e)for(let t=0;t0?n:"",s=t["uv"+r];void 0!==s&&(i+=`\n\t\ttexCoord2f[] primvars:st${r} = [${I_(s,e)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}return i}(i,n)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(t);return`\ndef "Geometry"\n{\n${e}\n}\n`}(e);i[a]=function(t){let e=y_();return e+=t,p_(e)}(t)}n.uuid in s||(s[n.uuid]=n),r+=function(t,e,i){const n="Object_"+t.id,r=x_(t.matrixWorld);t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t);return`def Xform "${n}" (\n\tprepend references = @./geometries/Geometry_${e.id}.usda@\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${r}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = \n}\n\n`}(t,e,n)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",t)}else t.isCamera&&(r+=function(t){const e=t.name?t.name:"Camera_"+t.id,i=x_(t.matrixWorld);t.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",t);return t.isOrthographicCamera?`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${i}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(__)}, ${t.far.toPrecision(__)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(t.left)+Math.abs(t.right))).toPrecision(__)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(t.top)+Math.abs(t.bottom))).toPrecision(__)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${e}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${i}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${t.near.toPrecision(__)}, ${t.far.toPrecision(__)})\n\t\t\tfloat focalLength = ${t.getFocalLength().toPrecision(__)}\n\t\t\tfloat focusDistance = ${t.focus.toPrecision(__)}\n\t\t\tfloat horizontalAperture = ${t.getFilmWidth().toPrecision(__)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${t.getFilmHeight().toPrecision(__)}\n\t\t}\n\t\n\t`} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */(t))})),r+="\n\t\t}\n\t}\n}\n\n",r+=function(t,e,i=!1){const n=[];for(const r in t){const s=t[r];n.push(w_(s,e,i))}return`def "Materials"\n{\n${n.join("")}\n}\n\n`}(s,a,e.quickLookCompatible),i[n]=p_(r),r=null;for(const t in a){const e=a[t],n=E_(e.image,e.flipY),r=await new Promise((t=>n.toBlob(t,"image/png",1)));i[`textures/Texture_${t}.png`]=new Uint8Array(await r.arrayBuffer())}let o=0;for(const t in i){const e=i[t];o+=34+t.length;const n=63&o;if(4!==n){const r=new Uint8Array(64-n);i[t]=[e,{extra:{12345:r}}]}o=e.length}return f_(i,{level:0})}}function E_(t,e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const i=1024/Math.max(t.width,t.height),n=document.createElement("canvas");n.width=t.width*Math.min(1,i),n.height=t.height*Math.min(1,i);const r=n.getContext("2d");return!0===e&&(r.translate(0,n.height),r.scale(1,-1)),r.drawImage(t,0,0,n.width,n.height),n}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const __=7;function y_(){return'#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tdefaultPrim = "Root"\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n'}function x_(t){const e=t.elements;return`( ${S_(e,0)}, ${S_(e,4)}, ${S_(e,8)}, ${S_(e,12)} )`}function S_(t,e){return`(${t[e+0]}, ${t[e+1]}, ${t[e+2]}, ${t[e+3]})`}function C_(t,e){if(void 0===t)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const i=[];for(let e=0;e0?"st"+n.channel:"st",l={1e3:"repeat",1001:"clamp",1002:"mirror"},c=n.repeat.clone(),h=n.offset.clone(),u=n.rotation,d=Math.sin(u),A=Math.cos(u);return h.y=1-h.y-c.y,i?(h.x=h.x/c.x,h.y=h.y/c.y,h.x+=d/c.x,h.y+=A-1):(h.x+=d*c.x,h.y+=(1-A)*c.y),`\n\t\tdef Shader "PrimvarReader_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdPrimvarReader_float2"\n\t\t\tfloat2 inputs:fallback = (0.0, 0.0)\n\t\t\ttoken inputs:varname = "${o}"\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Transform2d_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdTransform2d"\n\t\t\ttoken inputs:in.connect = \n\t\t\tfloat inputs:rotation = ${(u*(180/Math.PI)).toFixed(__)}\n\t\t\tfloat2 inputs:scale = ${b_(c)}\n\t\t\tfloat2 inputs:translation = ${b_(h)}\n\t\t\tfloat2 outputs:result\n\t\t}\n\n\t\tdef Shader "Texture_${n.id}_${r}"\n\t\t{\n\t\t\tuniform token info:id = "UsdUVTexture"\n\t\t\tasset inputs:file = @textures/Texture_${a}.png@\n\t\t\tfloat2 inputs:st.connect = \n\t\t\t${void 0!==s?"float4 inputs:scale = "+function(t){return`(${t.r}, ${t.g}, ${t.b}, 1.0)`}(s):""}\n\t\t\ttoken inputs:sourceColorSpace = "${n.colorSpace===dt?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${l[n.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${l[n.wrapT]}"\n\t\t\tfloat outputs:r\n\t\t\tfloat outputs:g\n\t\t\tfloat outputs:b\n\t\t\tfloat3 outputs:rgb\n\t\t\t${t.transparent||t.alphaTest>0?"float outputs:a":""}\n\t\t}`}return t.side===c&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",t),null!==t.map?(r.push(`${n}color3f inputs:diffuseColor.connect = `),t.transparent?r.push(`${n}float inputs:opacity.connect = `):t.alphaTest>0&&(r.push(`${n}float inputs:opacity.connect = `),r.push(`${n}float inputs:opacityThreshold = ${t.alphaTest}`)),s.push(a(t.map,"diffuse",t.color))):r.push(`${n}color3f inputs:diffuseColor = ${M_(t.color)}`),null!==t.emissiveMap?(r.push(`${n}color3f inputs:emissiveColor.connect = `),s.push(a(t.emissiveMap,"emissive"))):t.emissive.getHex()>0&&r.push(`${n}color3f inputs:emissiveColor = ${M_(t.emissive)}`),null!==t.normalMap&&(r.push(`${n}normal3f inputs:normal.connect = `),s.push(a(t.normalMap,"normal"))),null!==t.aoMap&&(r.push(`${n}float inputs:occlusion.connect = `),s.push(a(t.aoMap,"occlusion"))),null!==t.roughnessMap&&1===t.roughness?(r.push(`${n}float inputs:roughness.connect = `),s.push(a(t.roughnessMap,"roughness"))):r.push(`${n}float inputs:roughness = ${t.roughness}`),null!==t.metalnessMap&&1===t.metalness?(r.push(`${n}float inputs:metallic.connect = `),s.push(a(t.metalnessMap,"metallic"))):r.push(`${n}float inputs:metallic = ${t.metalness}`),null!==t.alphaMap?(r.push(`${n}float inputs:opacity.connect = `),r.push(`${n}float inputs:opacityThreshold = 0.0001`),s.push(a(t.alphaMap,"opacity"))):r.push(`${n}float inputs:opacity = ${t.opacity}`),t.isMeshPhysicalMaterial&&(r.push(`${n}float inputs:clearcoat = ${t.clearcoat}`),r.push(`${n}float inputs:clearcoatRoughness = ${t.clearcoatRoughness}`),r.push(`${n}float inputs:ior = ${t.ior}`)),`\n\tdef Material "Material_${t.id}"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n${r.join("\n")}\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = \n\n${s.join("\n")}\n\n\t}\n`}function M_(t){return`(${t.r}, ${t.g}, ${t.b})`}function b_(t){return`(${t.x}, ${t.y})`} +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var T_=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};let B_=!1,R_=!1;const L_="#model-viewer-no-ar-fallback",D_=(U_=["quick-look","scene-viewer","webxr","none"],t=>{try{const e=TA(t),i=(e.length?e[0].terms:[]).filter((t=>t&&"ident"===t.type)).map((t=>t.value)).filter((t=>U_.indexOf(t)>-1)),n=new Set;for(const t of i)n.add(t);return n}catch(t){}return new Set});var U_;const P_="quick-look",N_="scene-viewer",Q_="webxr",F_="none",O_=Symbol("arButtonContainer"),k_=Symbol("enterARWithWebXR"),G_=Symbol("openSceneViewer"),H_=Symbol("openIOSARQuickLook"),z_=Symbol("canActivateAR"),V_=Symbol("arMode"),W_=Symbol("arModes"),q_=Symbol("arAnchor"),X_=Symbol("preload"),j_=Symbol("onARButtonContainerClick"),Y_=Symbol("onARStatus"),K_=Symbol("onARTracking"),J_=Symbol("onARTap"),$_=Symbol("selectARMode"),Z_=Symbol("triggerLoad"); +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var ty=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const ey="auto",iy="auto",ny="eager",ry=Symbol("defaultProgressBarElement"),sy=Symbol("posterContainerElement"),ay=Symbol("defaultPosterElement"),oy=Symbol("shouldDismissPoster"),ly=Symbol("hidePoster"),cy=Symbol("modelIsRevealed"),hy=Symbol("updateProgressBar"),uy=Symbol("ariaLabelCallToAction"),dy=Symbol("onProgress"); +/* @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +var Ay=function(t,e,i,n){for(var r,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,o=t.length-1;o>=0;o--)(r=t[o])&&(a=(s<3?r(a):s>3?r(e,i,a):r(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a};const py=Math.PI/32,my={basis:[FA(bA(py,"rad"))],keywords:{auto:[null]}},gy=Symbol("autoRotateStartTime"),fy=Symbol("radiansPerSecond"),vy=Symbol("syncRotationRate"),Ey=Symbol("onCameraChange"),_y=(t=>{var e,i,n;class r extends t{constructor(){super(...arguments),this[e]=new Map,this[i]=t=>{t.forEach((t=>{t instanceof MutationRecord&&"childList"!==t.type||(t.addedNodes.forEach((t=>{this[CE](t)})),t.removedNodes.forEach((t=>{this[IE](t)})),this[sE]())}))},this[n]=new MutationObserver(this[xE])}connectedCallback(){super.connectedCallback();for(let t=0;t{var i,n,r;class s extends t{constructor(){super(...arguments),this[i]=void 0,this[n]=null,this[r]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[$f]}get availableVariants(){return this.model?this.model[Vf]():[]}get originalGltfJson(){return this[Jf]}[(i=$f,n=Kf,r=Jf,Zf)](){return()=>{this[sE]()}}[tv](t){return t.colorSpace=At,t.wrapS=C,t.wrapT=C,new kg(this[Zf](),t)}async createTexture(t,e="image/png"){const{textureUtils:i}=this[cE],n=await i.loadImage(t);return n.userData.mimeType=e,this[tv](n)}async createLottieTexture(t,e=1){const{textureUtils:i}=this[cE],n=await i.loadLottie(t,e);return this[tv](n)}createVideoTexture(t){const e=document.createElement("video");e.src=t,e.muted=!0,e.playsInline=!0,e.loop=!0,e.play();const i=new po(e);return this[tv](i)}createCanvasTexture(){const t=document.createElement("canvas"),e=new vo(t);return this[tv](e)}async updated(t){if(super.updated(t),t.has("variantName")){const t=this[hE].beginActivity();t(.1);const e=this[$f],{variantName:i}=this;null!=e&&(await e[Of](i),this[sE](),this.dispatchEvent(new CustomEvent("variant-applied"))),t(1)}if(t.has("orientation")||t.has("scale")){if(!this.loaded)return;const t=this[rE];t.applyTransform(),t.updateBoundingBox(),t.updateShadow(),this[cE].arRenderer.onUpdateScene(),this[sE]()}}[oE](){super[oE]();const{currentGLTF:t}=this[rE];if(null!=t){const{correlatedSceneGraph:e}=t;null!=e&&t!==this[Kf]&&(this[$f]=new jf(e,this[Zf]()),this[Jf]=JSON.parse(JSON.stringify(e.gltf))),"variants"in t.userData&&this.requestUpdate("variantName")}this[Kf]=t}async exportScene(t){const e=this[rE];return new Promise((async(i,n)=>{const r={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(r,t),r.animations=e.animations,r.truncateDrawRange=!0;const s=e.shadow;let a=!1;null!=s&&(a=s.visible,s.visible=!1),await this[$f][Ff]();(new wd).register((t=>new EA(t))).parse(e.model,(t=>i(new Blob([r.binary?t:JSON.stringify(t)],{type:r.binary?"application/octet-stream":"application/json"}))),(()=>n("glTF export failed")),r),null!=s&&(s.visible=a)}))}materialFromPoint(t,e){const i=this[$f];if(null==i)return null;const n=this[rE],r=n.getNDC(t,e),s=n.hitFromPoint(r);return null==s||null==s.face?null:i[kf](s)}}return Yf([e({type:String,attribute:"variant-name"})],s.prototype,"variantName",void 0),Yf([e({type:String,attribute:"orientation"})],s.prototype,"orientation",void 0),Yf([e({type:String,attribute:"scale"})],s.prototype,"scale",void 0),s})((t=>{var i,n,r;class s extends t{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=3e3,this.rotationPerSecond="auto",this[i]=performance.now(),this[n]=0,this[r]=t=>{this.autoRotate&&"user-interaction"===t.detail.source&&(this[gy]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[Ey]),this[gy]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[Ey]),this[gy]=performance.now()}updated(t){super.updated(t),t.has("autoRotate")&&(this[gy]=performance.now())}[(i=gy,n=fy,vy)](t){this[fy]=t[0]}[aE](t,e){if(super[aE](t,e),!this.autoRotate||!this[dE]()||this[cE].isPresenting)return;const i=Math.min(e,t-this[gy]-this.autoRotateDelay);i>0&&(this[rE].yaw=this.turntableRotation+this[fy]*i*.001)}get turntableRotation(){return this[rE].yaw}resetTurntableRotation(t=0){this[rE].yaw=t}}return r=Ey,Ay([e({type:Boolean,attribute:"auto-rotate"})],s.prototype,"autoRotate",void 0),Ay([e({type:Number,attribute:"auto-rotate-delay"})],s.prototype,"autoRotateDelay",void 0),Ay([Cp({intrinsics:my,updateHandler:vy}),e({type:String,attribute:"rotation-per-second"})],s.prototype,"rotationPerSecond",void 0),s})((t=>{var i,n,r;class s extends t{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=0,this.shadowSoftness=1,this.exposure=1,this.toneMapping="auto",this[i]=null,this[n]=null,this[r]=null}updated(t){super.updated(t),t.has("shadowIntensity")&&(this[rE].setShadowIntensity(.5*this.shadowIntensity),this[sE]()),t.has("shadowSoftness")&&(this[rE].setShadowSoftness(this.shadowSoftness),this[sE]()),t.has("exposure")&&(this[rE].exposure=this.exposure,this[sE]()),t.has("toneMapping")&&(this[rE].toneMapping=this.toneMapping,this[sE]()),(t.has("environmentImage")||t.has("skyboxImage"))&&this[AE]()&&this[fh]()}hasBakedShadow(){return this[rE].bakedShadows.size>0}async[(i=mh,n=gh,r=vh,fh)](){const{skyboxImage:t,environmentImage:e}=this;null!=this[vh]&&(this[vh](),this[vh]=null);const{textureUtils:i}=this[cE];if(null==i)return;const n=this[hE].beginActivity();try{const{environmentMap:r,skybox:s}=await i.generateEnvironmentMapAndSkybox(oh(t),e,(t=>n(uh(t,0,1))));this[mh]!==r&&(this[mh]=r,this.dispatchEvent(new CustomEvent("environment-change"))),this[gh]=null!=s?s.name===r.name?r:s:null,this[rE].setEnvironmentAndSkybox(this[mh],this[gh])}catch(t){if(t instanceof Error)throw this[rE].setEnvironmentAndSkybox(null,null),t}finally{n(1)}}}return ph([e({type:String,attribute:"environment-image"})],s.prototype,"environmentImage",void 0),ph([e({type:String,attribute:"skybox-image"})],s.prototype,"skyboxImage",void 0),ph([e({type:Number,attribute:"shadow-intensity"})],s.prototype,"shadowIntensity",void 0),ph([e({type:Number,attribute:"shadow-softness"})],s.prototype,"shadowSoftness",void 0),ph([e({type:Number})],s.prototype,"exposure",void 0),ph([e({type:String,attribute:"tone-mapping"})],s.prototype,"toneMapping",void 0),s})((t=>{var i,n,r,s,a,o,l,c,h,u,d,A,p,m,g,f,v;class E extends t{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=Rp,this.cameraTarget="auto auto auto",this.fieldOfView="auto",this.minCameraOrbit="auto",this.maxCameraOrbit="auto",this.minFieldOfView="auto",this.maxFieldOfView="auto",this.interactionPromptThreshold=3e3,this.interactionPrompt=Up,this.interactionPromptStyle=Np,this.orbitSensitivity=1,this.zoomSensitivity=1,this.panSensitivity=1,this.touchAction=Qp,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=50,this[i]=this.shadowRoot.querySelector(".interaction-prompt"),this[n]=this.shadowRoot.querySelector("#prompt"),this[r]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[s]=this.shadowRoot.querySelector(".pan-target"),this[a]=0,this[o]=1/0,this[l]=!1,this[c]=!1,this[h]=wm.AUTOMATIC,this[u]=new Mm(this[rE].camera,this[iE],this[rE]),this[d]=new Ml,this[A]=!1,this[p]=!1,this[m]=!1,this[g]=()=>{const t=this[jp].changeSource;this[cm]=t,t===wm.USER_INTERACTION&&(this[am]=!0,this[Zp]())},this[f]=()=>{this[tm](),this[sE]();const t=this[jp].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:t}}))},this[v]=t=>{"pointer-change-start"===t.type?this[eE].classList.add("pointer-tumbling"):this[eE].classList.remove("pointer-tumbling")}}get inputSensitivity(){return this[jp].inputSensitivity}set inputSensitivity(t){this[jp].inputSensitivity=t}getCameraOrbit(){const{theta:t,phi:e,radius:i}=this[hm];return{theta:t,phi:e,radius:i,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return pE(this[cE].isPresenting?this[cE].arRenderer.target:this[rE].getTarget())}getFieldOfView(){return this[jp].getFieldOfView()}getMinimumFieldOfView(){return this[jp].options.minimumFieldOfView}getMaximumFieldOfView(){return this[jp].options.maximumFieldOfView}getIdealAspect(){return this[rE].idealAspect}jumpCameraToGoal(){this[um]=!0,this.requestUpdate(um,!1)}resetInteractionPrompt(){this[lm]=0,this[om]=1/0,this[am]=!1,this[sm]=this.interactionPrompt===Up&&this.cameraControls}zoom(t){const e=new WheelEvent("wheel",{deltaY:-30*t});this[iE].dispatchEvent(e)}connectedCallback(){super.connectedCallback(),this[jp].addEventListener("user-interaction",this[im]),this[jp].addEventListener("pointer-change-start",this[rm]),this[jp].addEventListener("pointer-change-end",this[rm])}disconnectedCallback(){super.disconnectedCallback(),this[jp].removeEventListener("user-interaction",this[im]),this[jp].removeEventListener("pointer-change-start",this[rm]),this[jp].removeEventListener("pointer-change-end",this[rm])}updated(t){super.updated(t);const e=this[jp],i=this[rE];if(t.has("cameraControls")&&(this.cameraControls?(e.enableInteraction(),this.interactionPrompt===Up&&(this[sm]=!0)):(e.disableInteraction(),this[Zp]()),this[iE].setAttribute("aria-label",this[jv])),t.has("disableZoom")&&(e.disableZoom=this.disableZoom),t.has("disablePan")&&(e.enablePan=!this.disablePan),t.has("disableTap")&&(e.enableTap=!this.disableTap),(t.has("interactionPrompt")||t.has("cameraControls")||t.has("src"))&&(this.interactionPrompt===Up&&this.cameraControls&&!this[am]?this[sm]=!0:this[Zp]()),t.has("interactionPromptStyle")&&(this[Jp].style.opacity=this.interactionPromptStyle==Pp?"1":"0"),t.has("touchAction")){const t=this.touchAction;e.applyOptions({touchAction:t}),e.updateTouchActionStyle()}t.has("orbitSensitivity")&&(e.orbitSensitivity=this.orbitSensitivity),t.has("zoomSensitivity")&&(e.zoomSensitivity=this.zoomSensitivity),t.has("panSensitivity")&&(e.panSensitivity=this.panSensitivity),t.has("interpolationDecay")&&(e.setDamperDecayTime(this.interpolationDecay),i.setTargetDamperDecayTime(this.interpolationDecay)),!0===this[um]&&Promise.resolve().then((()=>{e.jumpToGoal(),i.jumpToGoal(),this[nm](),this[um]=!1}))}async updateFraming(){const t=this[rE],e=t.adjustedFoV(t.framedFoVDeg);await t.updateFraming();const i=t.adjustedFoV(t.framedFoVDeg),n=this[jp].getFieldOfView()/e;this[jp].setFieldOfView(i*n),this[Am]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(t,e,i){const n=this[iE],r=this[$p];if("1"===r[0].style.opacity)return void console.warn("interact() failed because an existing interaction is running.");const s=new Array;s.push({x:Mp(e.x),y:Mp(e.y)});const a=[{x:s[0].x(0),y:s[0].y(0)}];null!=i&&(s.push({x:Mp(i.x),y:Mp(i.y)}),a.push({x:s[1].x(0),y:s[1].y(0)}));let o=performance.now();const{width:l,height:c}=this[rE],h=this.getBoundingClientRect(),u=t=>{for(const[e,i]of a.entries()){const{style:s}=r[e];s.transform=`translateX(${l*i.x}px) translateY(${c*i.y}px)`,"pointerdown"===t?s.opacity="1":"pointerup"===t&&(s.opacity="0");const a={pointerId:e-5678,pointerType:"touch",target:n,clientX:l*i.x+h.x,clientY:c*i.y+h.y,altKey:!0};n.dispatchEvent(new PointerEvent(t,a))}},d=()=>{const e=this[cm];if(e!==wm.AUTOMATIC||!n.isConnected){for(const t of this[$p])t.style.opacity="0";return u("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:e}})),void document.removeEventListener("visibilitychange",A)}const i=Math.min(1,(performance.now()-o)/t);for(const[t,e]of a.entries())e.x=s[t].x(i),e.y=s[t].y(i);u("pointermove"),i<1?requestAnimationFrame(d):(u("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:wm.AUTOMATIC}})),document.removeEventListener("visibilitychange",A))},A=()=>{let t=0;"hidden"===document.visibilityState?t=performance.now()-o:o=performance.now()-t};document.addEventListener("visibilitychange",A),u("pointerdown"),this[cm]=wm.AUTOMATIC,requestAnimationFrame(d)}[(i=Kp,n=Jp,r=$p,s=Yp,a=lm,o=om,l=am,c=sm,h=cm,u=jp,d=hm,A=um,p=dm,m=Am,mm)](t){const e=this[jp],i=this[rE];i.framedFoVDeg=180*t[0]/Math.PI,e.changeSource=wm.NONE,e.setFieldOfView(i.adjustedFoV(i.framedFoVDeg)),this[im]()}[pm](t){const e=this[jp];if(this[Am]){const{theta:e,phi:i}=this.getCameraOrbit();t[0]=e,t[1]=i,this[Am]=!1}e.changeSource=wm.NONE,e.setOrbit(t[0],t[1],t[2]),this[im]()}[fm](t){this[jp].applyOptions({minimumAzimuthalAngle:t[0],minimumPolarAngle:t[1],minimumRadius:t[2]}),this.jumpCameraToGoal()}[vm](t){this[jp].applyOptions({maximumAzimuthalAngle:t[0],maximumPolarAngle:t[1],maximumRadius:t[2]}),this[em](t[2]),this.jumpCameraToGoal()}[Em](t){this[jp].applyOptions({minimumFieldOfView:180*t[0]/Math.PI}),this.jumpCameraToGoal()}[_m](t){const e=this[rE].adjustedFoV(180*t[0]/Math.PI);this[jp].applyOptions({maximumFieldOfView:e}),this.jumpCameraToGoal()}[gm](t){const[e,i,n]=t;this[cE].arRenderer.isPresenting||this[rE].setTarget(e,i,n),this[jp].changeSource=wm.NONE,this[cE].arRenderer.updateTarget(),this[im]()}[aE](t,e){if(super[aE](t,e),this[cE].isPresenting||!this[dE]())return;const i=this[jp],n=this[rE],r=performance.now();if(this[sm]&&this.loaded&&r>this[$v]+this.interactionPromptThreshold&&(this[sm]=!1,this[om]=r,this[Kp].classList.add("visible")),isFinite(this[om])&&this.interactionPromptStyle===Np){const t=(r-this[om])/5e3%1,e=Tp(t),s=Bp(t);if(this[Jp].style.opacity=`${s}`,e!==this[lm]){const t=e*n.width*.05,r=(e-this[lm])*Math.PI/16;this[Jp].style.transform=`translateX(${t}px)`,i.changeSource=wm.AUTOMATIC,i.adjustOrbit(r,0,0),this[lm]=e}}const s=i.update(t,e),a=n.updateTarget(e);(s||a)&&this[nm]()}[Zp](){this[sm]=!1,this[Kp].classList.remove("visible"),this[om]=1/0}[em](t){const e=Math.max(this[rE].boundingSphere.radius,t),i=Math.abs(2*e);this[jp].updateNearFar(0,i)}[tm](){const{theta:t,phi:e}=this[jp].getCameraSpherical(this[hm]),i=(4+Math.floor((t%Xp+qp)/Vp))%4,n=Math.floor(e/Wp),r=Lp[i],s=Dp[n];this[Jv](`View from stage ${s}${r}`)}get[jv](){return super[jv].replace(/\.$/,"")+(this.cameraControls?". Use mouse, touch or arrow keys to move.":"")}async[lE](t){const e=this[jp],i=this[rE],n=i.adjustedFoV(i.framedFoVDeg);super[lE](t);const r=i.adjustedFoV(i.framedFoVDeg)/n,s=e.getFieldOfView()*(isFinite(r)?r:1);e.updateAspect(this[rE].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[jp].setFieldOfView(s),this.jumpCameraToGoal()}[oE](){super[oE](),this[dm]?this[Am]=!0:this[dm]=!0,this.requestUpdate("maxFieldOfView",this.maxFieldOfView),this.requestUpdate("fieldOfView",this.fieldOfView),this.requestUpdate("minCameraOrbit",this.minCameraOrbit),this.requestUpdate("maxCameraOrbit",this.maxCameraOrbit),this.requestUpdate("cameraOrbit",this.cameraOrbit),this.requestUpdate("cameraTarget",this.cameraTarget),this.jumpCameraToGoal()}}return g=im,f=nm,v=rm,bp([e({type:Boolean,attribute:"camera-controls"})],E.prototype,"cameraControls",void 0),bp([Cp({intrinsics:kp,observeEffects:!0,updateHandler:pm}),e({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],E.prototype,"cameraOrbit",void 0),bp([Cp({intrinsics:zp,observeEffects:!0,updateHandler:gm}),e({type:String,attribute:"camera-target",hasChanged:()=>!0})],E.prototype,"cameraTarget",void 0),bp([Cp({intrinsics:Fp,observeEffects:!0,updateHandler:mm}),e({type:String,attribute:"field-of-view",hasChanged:()=>!0})],E.prototype,"fieldOfView",void 0),bp([Cp({intrinsics:Gp,updateHandler:fm}),e({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],E.prototype,"minCameraOrbit",void 0),bp([Cp({intrinsics:Hp,updateHandler:vm}),e({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],E.prototype,"maxCameraOrbit",void 0),bp([Cp({intrinsics:Op,updateHandler:Em}),e({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],E.prototype,"minFieldOfView",void 0),bp([Cp({intrinsics:Fp,updateHandler:_m}),e({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],E.prototype,"maxFieldOfView",void 0),bp([e({type:Number,attribute:"interaction-prompt-threshold"})],E.prototype,"interactionPromptThreshold",void 0),bp([e({type:String,attribute:"interaction-prompt"})],E.prototype,"interactionPrompt",void 0),bp([e({type:String,attribute:"interaction-prompt-style"})],E.prototype,"interactionPromptStyle",void 0),bp([e({type:Number,attribute:"orbit-sensitivity"})],E.prototype,"orbitSensitivity",void 0),bp([e({type:Number,attribute:"zoom-sensitivity"})],E.prototype,"zoomSensitivity",void 0),bp([e({type:Number,attribute:"pan-sensitivity"})],E.prototype,"panSensitivity",void 0),bp([e({type:String,attribute:"touch-action"})],E.prototype,"touchAction",void 0),bp([e({type:Boolean,attribute:"disable-zoom"})],E.prototype,"disableZoom",void 0),bp([e({type:Boolean,attribute:"disable-pan"})],E.prototype,"disablePan",void 0),bp([e({type:Boolean,attribute:"disable-tap"})],E.prototype,"disableTap",void 0),bp([e({type:Number,attribute:"interpolation-decay"})],E.prototype,"interpolationDecay",void 0),E})((t=>{var i,n,r,s,a,o,l,c,h,u;class d extends t{constructor(){super(...arguments),this.ar=!1,this.arScale="auto",this.arPlacement="floor",this.arModes="webxr scene-viewer quick-look",this.iosSrc=null,this.xrEnvironment=!1,this[i]=!1,this[n]=this.shadowRoot.querySelector(".ar-button"),this[r]=document.createElement("a"),this[s]=new Set,this[a]=F_,this[o]=!1,this[l]=t=>{t.preventDefault(),this.activateAR()},this[c]=({status:t})=>{t!==bm&&this[cE].arRenderer.presentedScene!==this[rE]||(this.setAttribute("ar-status",t),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:t}})),t===bm?this.removeAttribute("ar-tracking"):t===Tm&&this.setAttribute("ar-tracking",Lm))},this[h]=({status:t})=>{this.setAttribute("ar-tracking",t),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:t}}))},this[u]=t=>{"_apple_ar_quicklook_button_tapped"==t.data&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[V_]!==F_}connectedCallback(){super.connectedCallback(),this[cE].arRenderer.addEventListener("status",this[Y_]),this.setAttribute("ar-status",bm),this[cE].arRenderer.addEventListener("tracking",this[K_]),this[q_].addEventListener("message",this[J_])}disconnectedCallback(){super.disconnectedCallback(),this[cE].arRenderer.removeEventListener("status",this[Y_]),this[cE].arRenderer.removeEventListener("tracking",this[K_]),this[q_].removeEventListener("message",this[J_])}update(t){super.update(t),t.has("arScale")&&(this[rE].canScale="fixed"!==this.arScale),t.has("arPlacement")&&(this[rE].updateShadow(),this[sE]()),t.has("arModes")&&(this[W_]=D_(this.arModes)),(t.has("ar")||t.has("arModes")||t.has("src")||t.has("iosSrc"))&&this[$_]()}async activateAR(){switch(this[V_]){case P_:await this[H_]();break;case Q_:await this[k_]();break;case N_:this[G_]();break;default:console.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities")}}async[(i=z_,n=O_,r=q_,s=W_,a=V_,o=X_,l=j_,c=Y_,h=K_,u=J_,$_)](){let t=F_;if(this.ar){if(null!=this.src)for(const e of this[W_]){if("webxr"===e&&Zc&&!B_&&await this[cE].arRenderer.supportsPresentation()){t=Q_;break}if("scene-viewer"===e&&rh&&!R_){t=N_;break}if("quick-look"===e&&ah){t=P_;break}}t===F_&&null!=this.iosSrc&&ah&&(t=P_)}if(t!==F_)this[O_].classList.add("enabled"),this[O_].addEventListener("click",this[j_]);else if(this[O_].classList.contains("enabled")){this[O_].removeEventListener("click",this[j_]),this[O_].classList.remove("enabled");const t=Rm;this.setAttribute("ar-status",t),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:t}}))}this[V_]=t}async[k_](){console.log("Attempting to present in AR with WebXR..."),await this[Z_]();try{this[O_].removeEventListener("click",this[j_]);const{arRenderer:t}=this[cE];t.placeOnWall="wall"===this.arPlacement,await t.present(this[rE],this.xrEnvironment)}catch(t){console.warn("Error while trying to present in AR with WebXR"),console.error(t),await this[cE].arRenderer.stopPresenting(),B_=!0,console.warn("Falling back to next ar-mode"),await this[$_](),this.activateAR()}finally{this[$_]()}}async[Z_](){this.loaded||(this[X_]=!0,this[Zv](),await((t,e,i=null)=>new Promise((n=>{t.addEventListener(e,(function r(s){i&&!i(s)||(n(s),t.removeEventListener(e,r))}))})))(this,"load"),this[X_]=!1)}[AE](){return super[AE]()||this[X_]}[G_](){const t=self.location.toString(),e=new URL(t),i=new URL(this.src,t);i.hash&&(i.hash="");const n=new URLSearchParams(i.search);if(e.hash=L_,n.set("mode","ar_preferred"),n.has("disable_occlusion")||n.set("disable_occlusion","true"),"fixed"===this.arScale&&n.set("resizable","false"),"wall"===this.arPlacement&&n.set("enable_vertical_placement","true"),n.has("sound")){const e=new URL(n.get("sound"),t);n.set("sound",e.toString())}if(n.has("link")){const e=new URL(n.get("link"),t);n.set("link",e.toString())}const r=`intent://arvr.google.com/scene-viewer/1.0?${n.toString()+"&file="+encodeURIComponent(i.toString())}#Intent;scheme=https;package=com.google.ar.core;action=android.intent.action.VIEW;S.browser_fallback_url=${encodeURIComponent(e.toString())};end;`;self.addEventListener("hashchange",(()=>{self.location.hash===L_&&(R_=!0,self.history.back(),console.warn("Error while trying to present in AR with Scene Viewer"),console.warn("Falling back to next ar-mode"),this[$_]())}),{once:!0}),this[q_].setAttribute("href",r),console.log("Attempting to present in AR with Scene Viewer..."),this[q_].click()}async[H_](){const t=!this.iosSrc;this[O_].classList.remove("enabled");const e=t?await this.prepareUSDZ():this.iosSrc,i=new URL(e,self.location.toString());if(t){const t=self.location.toString(),e=new URL(t),n=new URL(this.src,e);n.hash&&(i.hash=n.hash)}"fixed"===this.arScale&&(i.hash&&(i.hash+="&"),i.hash+="allowsContentScaling=0");const n=this[q_];n.setAttribute("rel","ar");const r=document.createElement("img");n.appendChild(r),n.setAttribute("href",i.toString()),t&&n.setAttribute("download","model.usdz"),n.style.display="none",n.isConnected||this.shadowRoot.appendChild(n),console.log("Attempting to present in AR with Quick Look..."),n.click(),n.removeChild(r),t&&URL.revokeObjectURL(e),this[O_].classList.add("enabled")}async prepareUSDZ(){const t=this[hE].beginActivity();await this[Z_]();const{model:e,shadow:i}=this[rE];if(null==e)return"";let n=!1;null!=i&&(n=i.visible,i.visible=!1),t(.2);const r=new v_,s=await r.parse(e),a=new Blob([s],{type:"model/vnd.usdz+zip"}),o=URL.createObjectURL(a);return t(1),null!=i&&(i.visible=n),o}}return T_([e({type:Boolean,attribute:"ar"})],d.prototype,"ar",void 0),T_([e({type:String,attribute:"ar-scale"})],d.prototype,"arScale",void 0),T_([e({type:String,attribute:"ar-placement"})],d.prototype,"arPlacement",void 0),T_([e({type:String,attribute:"ar-modes"})],d.prototype,"arModes",void 0),T_([e({type:String,attribute:"ios-src"})],d.prototype,"iosSrc",void 0),T_([e({type:Boolean,attribute:"xr-environment"})],d.prototype,"xrEnvironment",void 0),d})((t=>{var i,n,r,s,a,o,l,c;class h extends t{constructor(...t){super(...t),this.poster=null,this.reveal=ey,this.loading=iy,this[i]=!1,this[n]=!1,this[r]=this.shadowRoot.querySelector(".slot.poster"),this[s]=this.shadowRoot.querySelector("#default-poster"),this[a]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[o]=this[ay].getAttribute("aria-label"),this[l]=((t,e)=>{let i=null;const n=(...n)=>{null==i&&(t(...n),i=self.setTimeout((()=>i=null),e))};return n.flush=()=>{null!=i&&(self.clearTimeout(i),i=null)},n})((t=>{const e=this[ry].parentNode;requestAnimationFrame((()=>{this[ry].style.transform=`scaleX(${t})`,0===t&&(e.removeChild(this[ry]),e.appendChild(this[ry])),1===t?this[ry].classList.add("hide"):this[ry].classList.remove("hide")}))}),100),this[c]=t=>{const e=t.detail.totalProgress;1===e&&(this[hy].flush(),this.loaded&&(this[oy]||this.reveal===ey)&&this[ly]()),this[hy](e),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:e}}))};const e=self.ModelViewerElement||{},h=e.dracoDecoderLocation||"https://www.gstatic.com/draco/versioned/decoders/1.5.6/";ud.setDRACODecoderLocation(h);const u=e.ktx2TranscoderLocation||"https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";ud.setKTX2TranscoderLocation(u),e.meshoptDecoderLocation&&ud.setMeshoptDecoderLocation(e.meshoptDecoderLocation);const d=e.lottieLoaderLocation||"https://cdn.jsdelivr.net/npm/three@0.149.0/examples/jsm/loaders/LottieLoader.js";dg.singleton.textureUtils.lottieLoaderUrl=d}static set dracoDecoderLocation(t){ud.setDRACODecoderLocation(t)}static get dracoDecoderLocation(){return ud.getDRACODecoderLocation()}static set ktx2TranscoderLocation(t){ud.setKTX2TranscoderLocation(t)}static get ktx2TranscoderLocation(){return ud.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(t){ud.setMeshoptDecoderLocation(t)}static get meshoptDecoderLocation(){return ud.getMeshoptDecoderLocation()}static set lottieLoaderLocation(t){dg.singleton.textureUtils.lottieLoaderUrl=t}static get lottieLoaderLocation(){return dg.singleton.textureUtils.lottieLoaderUrl}static mapURLs(t){dg.singleton.loader[ld].manager.setURLModifier(t)}dismissPoster(){this.loaded?this[ly]():(this[oy]=!0,this[Zv]())}showPoster(){const t=this[sy];if(t.classList.contains("show"))return;t.classList.add("show"),this[iE].classList.remove("show");const e=this[ay];e.removeAttribute("tabindex"),e.removeAttribute("aria-hidden");const i=this.modelIsVisible;this[cy]=!1,this[Xv](i)}getDimensions(){return pE(this[rE].size)}getBoundingBoxCenter(){return pE(this[rE].boundingBox.getCenter(new ge))}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[hE].addEventListener("progress",this[dy])}disconnectedCallback(){super.disconnectedCallback(),this[hE].removeEventListener("progress",this[dy])}async updated(t){super.updated(t),t.has("poster")&&null!=this.poster&&(this[ay].style.backgroundImage=`url(${this.poster})`),t.has("alt")&&this[ay].setAttribute("aria-label",this[Yv]),(t.has("reveal")||t.has("loading"))&&this[Zv]()}[(i=cy,n=oy,r=sy,s=ay,a=ry,o=uy,l=hy,c=dy,AE)](){return!!this.src&&(this[oy]||this.loading===ny||this.reveal===ey&&this[qv])}[ly](){this[oy]=!1;const t=this[sy];if(!t.classList.contains("show"))return;t.classList.remove("show"),this[iE].classList.add("show");const e=this.modelIsVisible;this[cy]=!0,this[Xv](e);const i=this.getRootNode();i&&i.activeElement===this&&this[iE].focus();const n=this[ay];n.setAttribute("aria-hidden","true"),n.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[dE](){return super[dE]()&&this[cy]}}return ty([e({type:String})],h.prototype,"poster",void 0),ty([e({type:String})],h.prototype,"reveal",void 0),ty([e({type:String})],h.prototype,"loading",void 0),h})((t=>{var i;class n extends t{constructor(...t){super(t),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[i]=!0,this[rE].subscribeMixerEvent("loop",(t=>{const e=t.action._loopCount;this.dispatchEvent(new CustomEvent("loop",{detail:{count:e}}))})),this[rE].subscribeMixerEvent("finished",(()=>{this[EE]=!0,this.dispatchEvent(new CustomEvent("finished"))}))}get availableAnimations(){return this.loaded?this[rE].animationNames:[]}get duration(){return this[rE].duration}get paused(){return this[EE]}get currentTime(){return this[rE].animationTime}set currentTime(t){this[rE].animationTime=t,this[sE]()}get timeScale(){return this[rE].animationTimeScale}set timeScale(t){this[rE].animationTimeScale=t}pause(){this[EE]||(this[EE]=!0,this.dispatchEvent(new CustomEvent("pause")))}play(t){this.availableAnimations.length>0&&(this[EE]=!1,this[vE](t),this.dispatchEvent(new CustomEvent("play")))}[(i=EE,oE)](){super[oE](),this[EE]=!0,null!=this.animationName&&this[vE](),this.autoplay&&this.play()}[aE](t,e){super[aE](t,e),this[EE]||!this[dE]()&&!this[cE].isPresenting||(this[rE].updateAnimation(e/1e3),this[sE]())}updated(t){super.updated(t),t.has("autoplay")&&this.autoplay&&this.play(),t.has("animationName")&&this[vE]()}[vE](t=_E){var e;const i=null!==(e=t.repetitions)&&void 0!==e?e:1/0,n=t.pingpong?nt:1===i?2200:it;this[rE].playAnimation(this.animationName,this.animationCrossfadeDuration/1e3,n,i),this[EE]&&(this[rE].updateAnimation(0),this[sE]())}}return fE([e({type:Boolean})],n.prototype,"autoplay",void 0),fE([e({type:String,attribute:"animation-name"})],n.prototype,"animationName",void 0),fE([e({type:Number,attribute:"animation-crossfade-duration"})],n.prototype,"animationCrossfadeDuration",void 0),n})(gE))))))));customElements.define("model-viewer",_y);export{vo as CanvasTexture,Wo as FileLoader,Ho as Loader,_y as ModelViewerElement,M as NearestFilter}; +//# sourceMappingURL=model-viewer.min.js.map diff --git a/Gruntfile.js b/Gruntfile.js index 7cf32651..a60e9348 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -228,7 +228,7 @@ module.exports = function(grunt) { }); grunt.registerTask('build', ['clean', 'copy:main', 'buildlessons']); - grunt.registerTask('buildwatch', [/*'build',*/ 'serve', 'watch']); + grunt.registerTask('buildwatch', ['build', 'serve', 'watch']); grunt.registerTask('default', ['eslint', 'build']); }; diff --git a/package-lock.json b/package-lock.json index fea2f486..9cfa46b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "license": "MIT", "devDependencies": { - "@gfxfundamentals/lesson-builder": "github:gfxfundamentals/lesson-builder#v2.2.4", + "@gfxfundamentals/lesson-builder": "github:gfxfundamentals/lesson-builder#v2.3.0", "@gfxfundamentals/live-editor": "github:gfxfundamentals/live-editor#v1.5.1", "@types/estree": "^1.0.0", "@types/jsdom": "^21.1.1", @@ -215,8 +215,8 @@ } }, "node_modules/@gfxfundamentals/lesson-builder": { - "version": "2.2.4", - "resolved": "git+ssh://git@github.com/gfxfundamentals/lesson-builder.git#f54fdba41d7f8e56384fe458464a83039f3e4e2b", + "version": "2.3.0", + "resolved": "git+ssh://git@github.com/gfxfundamentals/lesson-builder.git#d1ec4cc1fbf0f80aea5d8feac271b1665d23076f", "dev": true, "license": "MIT", "dependencies": { @@ -5889,9 +5889,9 @@ "dev": true }, "@gfxfundamentals/lesson-builder": { - "version": "git+ssh://git@github.com/gfxfundamentals/lesson-builder.git#f54fdba41d7f8e56384fe458464a83039f3e4e2b", + "version": "git+ssh://git@github.com/gfxfundamentals/lesson-builder.git#d1ec4cc1fbf0f80aea5d8feac271b1665d23076f", "dev": true, - "from": "@gfxfundamentals/lesson-builder@github:gfxfundamentals/lesson-builder#v2.2.4", + "from": "@gfxfundamentals/lesson-builder@github:gfxfundamentals/lesson-builder#v2.3.0", "requires": { "@gfxfundamentals/thumbnail-gen": "git://github.com/gfxfundamentals/thumbnail-gen.git#v1.0.3", "ansi-colors": "^4.1.3", diff --git a/package.json b/package.json index 9f3197bb..36460fca 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Some webgpu Tutorials", "main": "index.js", "devDependencies": { - "@gfxfundamentals/lesson-builder": "github:gfxfundamentals/lesson-builder#v2.2.4", + "@gfxfundamentals/lesson-builder": "github:gfxfundamentals/lesson-builder#v2.3.0", "@gfxfundamentals/live-editor": "github:gfxfundamentals/live-editor#v1.5.1", "@types/estree": "^1.0.0", "@types/jsdom": "^21.1.1", diff --git a/toc.hanson b/toc.hanson index e6f4314d..600699e8 100644 --- a/toc.hanson +++ b/toc.hanson @@ -5,9 +5,14 @@ 'webgpu-uniforms.md', 'webgpu-storage-buffers.md', 'webgpu-vertex-buffers.md', - 'webgpu-textures.md', - 'webgpu-importing-textures.md', - 'webgpu-textures-external-video.md', + { + 'textures': [ + 'webgpu-textures.md', + 'webgpu-importing-textures.md', + 'webgpu-textures-external-video.md', + 'webgpu-cube-maps.md', + ], + }, 'webgpu-constants.md', 'webgpu-memory-layout.md', 'webgpu-copying-data.md', diff --git a/webgpu/lessons/langinfo.hanson b/webgpu/lessons/langinfo.hanson index 933c8f64..c5b01ed3 100644 --- a/webgpu/lessons/langinfo.hanson +++ b/webgpu/lessons/langinfo.hanson @@ -29,6 +29,7 @@ Sorry this article has not been translated yet. categoryMapping: { 'basics': 'Basics', 'misc': 'Misc', + 'textures': 'Textures', 'reference': 'Reference', '3d-math': '3D Math', 'lighting': 'Lighting', diff --git a/webgpu/lessons/resources/cube-normals.html b/webgpu/lessons/resources/cube-normals.html new file mode 100644 index 00000000..f5c0e767 --- /dev/null +++ b/webgpu/lessons/resources/cube-normals.html @@ -0,0 +1,314 @@ + + + + + + +Per Face Per Vertex vs Shared Normals Diagram + + + + + + + + + + + + + + + diff --git a/webgpu/lessons/resources/noodles-01.jpg b/webgpu/lessons/resources/noodles-01.jpg new file mode 100644 index 00000000..e22b51cd Binary files /dev/null and b/webgpu/lessons/resources/noodles-01.jpg differ diff --git a/webgpu/lessons/resources/noodles-02.jpg b/webgpu/lessons/resources/noodles-02.jpg new file mode 100644 index 00000000..a44423d3 Binary files /dev/null and b/webgpu/lessons/resources/noodles-02.jpg differ diff --git a/webgpu/lessons/resources/noodles-03.jpg b/webgpu/lessons/resources/noodles-03.jpg new file mode 100644 index 00000000..3a86f0fd Binary files /dev/null and b/webgpu/lessons/resources/noodles-03.jpg differ diff --git a/webgpu/lessons/resources/noodles-04.jpg b/webgpu/lessons/resources/noodles-04.jpg new file mode 100644 index 00000000..14d236c4 Binary files /dev/null and b/webgpu/lessons/resources/noodles-04.jpg differ diff --git a/webgpu/lessons/resources/noodles-05.jpg b/webgpu/lessons/resources/noodles-05.jpg new file mode 100644 index 00000000..d2521868 Binary files /dev/null and b/webgpu/lessons/resources/noodles-05.jpg differ diff --git a/webgpu/lessons/resources/noodles-06.jpg b/webgpu/lessons/resources/noodles-06.jpg new file mode 100644 index 00000000..c4421263 Binary files /dev/null and b/webgpu/lessons/resources/noodles-06.jpg differ diff --git a/webgpu/lessons/webgpu-cube-maps.md b/webgpu/lessons/webgpu-cube-maps.md new file mode 100644 index 00000000..5b066add --- /dev/null +++ b/webgpu/lessons/webgpu-cube-maps.md @@ -0,0 +1,473 @@ +Title: WebGPU Cubemaps +Description: How to use cubemaps in WebGPU +TOC: Cube Maps + +This article assumes you've read [the article on textures](webgpu-textures.html) and [the article on importing images into textures](webgpu-importing-textures.html). +This article also uses concepts covered in [the article on directional lighting](webgpu-lighting-directional.html). +If you have not read those articles already you might want to read them first. + +In a [previous article](webgpu-textures.html) we covered how to use textures, +how they are referenced by texture coordinates that go from 0 to 1 across and up +the texture, and how they are filtered optionally using mips. + +Another kind of texture is a *cubemap*. A cubemap consists of 6 faces representing +the 6 faces of a cube. Instead of the traditional texture coordinates that +have 2 dimensions, a cubemap uses a normal or in other words a 3D direction. +Depending on the direction the normal points one of the 6 faces of the cube +is selected and then within that face the pixels are sampled to produce a color. + +Let's make a simple example, we'll use a 2D canvas to make the images used in +each of the 6 faces. + +Here's some code to fill a canvas with a color and a centered message + +```js +function generateFace(size, {faceColor, textColor, text}) { + const canvas = document.createElement('canvas'); + canvas.width = size; + canvas.height = size; + const ctx = canvas.getContext('2d'); + ctx.fillStyle = faceColor; + ctx.fillRect(0, 0, size, size); + ctx.font = `${size * 0.7}px sans-serif`; + ctx.textAlign = 'center'; + ctx.textBaseline = 'middle'; + ctx.fillStyle = textColor; + ctx.fillText(text, size / 2, size / 2); + return canvas; +} +``` + +And here's some code to call it to generate 6 images + +```js +const faceSize = 128; +const faceCanvases = [ + { faceColor: '#F00', textColor: '#0FF', text: '+X' }, + { faceColor: '#FF0', textColor: '#00F', text: '-X' }, + { faceColor: '#0F0', textColor: '#F0F', text: '+Y' }, + { faceColor: '#0FF', textColor: '#F00', text: '-Y' }, + { faceColor: '#00F', textColor: '#FF0', text: '+Z' }, + { faceColor: '#F0F', textColor: '#0F0', text: '-Z' }, +].map(faceInfo => generateFace(faceSize, faceInfo)); + +// show the results +for (const canvas of faceCanvases) { + document.body.appendChild(canvas); +} +``` + +{{{example url="../webgpu-cube-faces.html" }}} + +Now let's apply those to a cube using a cubemap. We'll start with the code +from the texture atlas example [in the article on importing textures](webgpu-importing-textures.html#a-texture-atlases). + +First off let's change the shaders to use a cube map + +```wgsl +struct Uniforms { + matrix: mat4x4f, +}; + +struct Vertex { + @location(0) position: vec4f, +- @location(1) texcoord: vec2f, +}; + +struct VSOutput { + @builtin(position) position: vec4f, +- @location(0) texcoord: vec2f, ++ @location(0) normal: vec3f, +}; + +... + +@vertex fn vs(vert: Vertex) -> VSOutput { + var vsOut: VSOutput; + vsOut.position = uni.matrix * vert.position; +- vsOut.texcoord = vert.texcoord; ++ vsOut.normal = normalize(vert.position.xyz); + return vsOut; +} +``` + +We've removed the texture coordinates from the shader and +changed the inter-stage variable to pass a normal to the fragment shader. +Since the positions of our cube are perfectly centered around the origin +we can just use them as our normals. + +Recall from [the article on lighting](webgpu-lighting-directional.html) that +normals are a direction and are usually used to specify the direction of +the surface of some vertex. Because we are using the normalized positions +for our normals if we were to light this we'd get smooth lighting across +the cube. + +{{{diagram url="resources/cube-normals.html" caption="standard cube normals vs this cube's normals" width="700" height="400"}}} + +Since we're not using texture coordinates we can remove all code related to +setting up the texture coordinates. + +```js + const vertexData = new Float32Array([ +- // front face select the top left image +- -1, 1, 1, 0 , 0 , +- -1, -1, 1, 0 , 0.5, +- 1, 1, 1, 0.25, 0 , +- 1, -1, 1, 0.25, 0.5, +- // right face select the top middle image +- 1, 1, -1, 0.25, 0 , +- 1, 1, 1, 0.5 , 0 , +- 1, -1, -1, 0.25, 0.5, +- 1, -1, 1, 0.5 , 0.5, +- // back face select to top right image +- 1, 1, -1, 0.5 , 0 , +- 1, -1, -1, 0.5 , 0.5, +- -1, 1, -1, 0.75, 0 , +- -1, -1, -1, 0.75, 0.5, +- // left face select the bottom left image +- -1, 1, 1, 0 , 0.5, +- -1, 1, -1, 0.25, 0.5, +- -1, -1, 1, 0 , 1 , +- -1, -1, -1, 0.25, 1 , +- // bottom face select the bottom middle image +- 1, -1, 1, 0.25, 0.5, +- -1, -1, 1, 0.5 , 0.5, +- 1, -1, -1, 0.25, 1 , +- -1, -1, -1, 0.5 , 1 , +- // top face select the bottom right image +- -1, 1, 1, 0.5 , 0.5, +- 1, 1, 1, 0.75, 0.5, +- -1, 1, -1, 0.5 , 1 , +- 1, 1, -1, 0.75, 1 , ++ // front face ++ -1, 1, 1, ++ -1, -1, 1, ++ 1, 1, 1, ++ 1, -1, 1, ++ // right face ++ 1, 1, -1, ++ 1, 1, 1, ++ 1, -1, -1, ++ 1, -1, 1, ++ // back face ++ 1, 1, -1, ++ 1, -1, -1, ++ -1, 1, -1, ++ -1, -1, -1, ++ // left face ++ -1, 1, 1, ++ -1, 1, -1, ++ -1, -1, 1, ++ -1, -1, -1, ++ // bottom face ++ 1, -1, 1, ++ -1, -1, 1, ++ 1, -1, -1, ++ -1, -1, -1, ++ // top face ++ -1, 1, 1, ++ 1, 1, 1, ++ -1, 1, -1, ++ 1, 1, -1, + ]); + + ... + + const pipeline = device.createRenderPipeline({ + label: '2 attributes', + layout: 'auto', + vertex: { + module, + entryPoint: 'vs', + buffers: [ + { +- arrayStride: (3 + 2) * 4, // (3+2) floats 4 bytes each ++ arrayStride: (3) * 4, // (3) floats 4 bytes each + attributes: [ + {shaderLocation: 0, offset: 0, format: 'float32x3'}, // position +- {shaderLocation: 1, offset: 12, format: 'float32x2'}, // texcoord + ], + }, + ], + }, + fragment: { + module, + entryPoint: 'fs', + targets: [{ format: presentationFormat }], + }, + primitive: { + cullMode: 'back', + }, + depthStencil: { + depthWriteEnabled: true, + depthCompare: 'less', + format: 'depth24plus', + }, + }); +``` + +In the fragment shader we need to use a `texture_cube` instead of a `texture_2d` +and `textureSample` when used with a `texture_cube` takes a `vec3f` direction +so we pass the normal. Since the normal is a inter-stage variable and will be interpolated +we need to normalize it. + +```wgsl +@group(0) @binding(0) var uni: Uniforms; +@group(0) @binding(1) var ourSampler: sampler; +-@group(0) @binding(2) var ourTexture: texture_2d; ++@group(0) @binding(2) var ourTexture: texture_cube; + +@fragment fn fs(vsOut: VSOutput) -> @location(0) vec4f { +- return textureSample(ourTexture, ourSampler, vsOut.texcoord); ++ return textureSample(ourTexture, ourSampler, normalize(vsOut.normal)); +} +``` + +To actually make a cube map we make a 2D texture with 6 layers. Let's change all our helpers +so they handle multiple sources. + +## Making our texture helpers handle multiple layers + +First let's take our `createTextureFromSource` and change it to `createTextureFromSources` +where it takes an array of sources + +```js +- function createTextureFromSource(device, source, options = {}) { ++ function createTextureFromSources(device, sources, options = {}) { ++ // Assume are sources all the same size so just use the first one for width and height ++ const source = sources[0]; + const texture = device.createTexture({ + format: 'rgba8unorm', + mipLevelCount: options.mips ? numMipLevels(source.width, source.height) : 1, +- size: [source.width, source.height], ++ size: [source.width, source.height, sources.length], + usage: GPUTextureUsage.TEXTURE_BINDING | + GPUTextureUsage.COPY_DST | + GPUTextureUsage.RENDER_ATTACHMENT, + }); +- copySourceToTexture(device, texture, source, options); ++ copySourcesToTexture(device, texture, sources, options); + return texture; + } +``` + +The code above makes a texture where multiple layers, one for each source. +It also assumes all the sources are the same size. This seems like a good bet +because it would be very rare for them to be different sizes for layers of the same texture. + +Now we need to update `copySourceToTexture` to handle multiple sources. + +```js +- function copySourceToTexture(device, texture, source, {flipY} = {}) { ++ function copySourcesToTexture(device, texture, sources, {flipY} = {}) { ++ sources.forEach((source, layer) => { +* device.queue.copyExternalImageToTexture( +* { source, flipY, }, +- { texture }, ++ { texture, origin: [0, 0, layer] }, +* { width: source.width, height: source.height }, +* ); ++ }); + + if (texture.mipLevelCount > 1) { + generateMips(device, texture); + } + } +``` + +Above, the only major difference is we added a loop to loop over the sources +and we set an `origin` for where in the texture to copy the source so that +we copy each source to its respective layer. + +Now we need to update `generateMips` to handle multiple sources. + +```js + const generateMips = (() => { + let sampler; + let module; + const pipelineByFormat = {}; + + return function generateMips(device, texture) { + if (!module) { + module = device.createShaderModule({ + label: 'textured quad shaders for mip level generation', + code: ` + struct VSOutput { + @builtin(position) position: vec4f, + @location(0) texcoord: vec2f, + }; + + @vertex fn vs( + @builtin(vertex_index) vertexIndex : u32 + ) -> VSOutput { + let pos = array( + + vec2f( 0.0, 0.0), // center + vec2f( 1.0, 0.0), // right, center + vec2f( 0.0, 1.0), // center, top + + // 2st triangle + vec2f( 0.0, 1.0), // center, top + vec2f( 1.0, 0.0), // right, center + vec2f( 1.0, 1.0), // right, top + ); + + var vsOutput: VSOutput; + let xy = pos[vertexIndex]; + vsOutput.position = vec4f(xy * 2.0 - 1.0, 0.0, 1.0); + vsOutput.texcoord = vec2f(xy.x, 1.0 - xy.y); + return vsOutput; + } + + @group(0) @binding(0) var ourSampler: sampler; + @group(0) @binding(1) var ourTexture: texture_2d; + + @fragment fn fs(fsInput: VSOutput) -> @location(0) vec4f { + return textureSample(ourTexture, ourSampler, fsInput.texcoord); + } + `, + }); + + sampler = device.createSampler({ + minFilter: 'linear', + magFilter: 'linear', + }); + } + + if (!pipelineByFormat[texture.format]) { + pipelineByFormat[texture.format] = device.createRenderPipeline({ + label: 'mip level generator pipeline', + layout: 'auto', + vertex: { + module, + entryPoint: 'vs', + }, + fragment: { + module, + entryPoint: 'fs', + targets: [{ format: texture.format }], + }, + }); + } + const pipeline = pipelineByFormat[texture.format]; + + const encoder = device.createCommandEncoder({ + label: 'mip gen encoder', + }); + + let width = texture.width; + let height = texture.height; + let baseMipLevel = 0; + while (width > 1 || height > 1) { + width = Math.max(1, width / 2 | 0); + height = Math.max(1, height / 2 | 0); + ++ for (let layer = 0; layer < texture.depthOrArrayLayers; ++layer) { +* const bindGroup = device.createBindGroup({ +* layout: pipeline.getBindGroupLayout(0), +* entries: [ +* { binding: 0, resource: sampler }, +- { binding: 1, resource: texture.createView({baseMipLevel, mipLevelCount: 1}) }, ++ { ++ binding: 1, ++ resource: texture.createView({ ++ dimension: '2d', ++ baseMipLevel, ++ mipLevelCount: 1, ++ baseArrayLayer: layer, ++ arrayLayerCount: 1, ++ }), +* }, +* ], +* }); +* +- ++baseMipLevel; +* +* const renderPassDescriptor = { +* label: 'our basic canvas renderPass', +* colorAttachments: [ +* { +- view: texture.createView({baseMipLevel, mipLevelCount: 1}), ++ view: texture.createView({ ++ dimension: '2d', ++ baseMipLevel: baseMipLevel + 1, ++ mipLevelCount: 1, ++ baseArrayLayer: layer, ++ arrayLayerCount: 1, ++ }), +* loadOp: 'clear', +* storeOp: 'store', +* }, +* ], +* }; +* +* const pass = encoder.beginRenderPass(renderPassDescriptor); +* pass.setPipeline(pipeline); +* pass.setBindGroup(0, bindGroup); +* pass.draw(6); // call our vertex shader 6 times +* pass.end(); ++ } ++ ++baseMipLevel; ++ } + + const commandBuffer = encoder.finish(); + device.queue.submit([commandBuffer]); + }; + })(); +``` + +We added a loop to handle each layer of the texture. +We changed the views so they select a single layer. We also had to explicitly choose +`dimension: '2d'` for our views because by default, a view of a 2d texture with more than +1 layer gets the `dimension: '2d-array'` which for the the purpose of generating +mipmaps is not what we want. + +Although we won't use them here, our original `createTextureFromSource` and +`copySourceToTexture` functions can easily be replaced with + +```js + function copySourceToTexture(device, texture, source, options = {}) { + copySourcesToTexture(device, texture, [source], options); + } + + function createTextureFromSource(device, source, options = {}) { + return createTextureFromSources(device, [source], options); + } +``` + +Now that we have these ready we can use the faces we made at the top of the article + +```js + const texture = await createTextureFromSources( + device, faceCanvases, {mips: true, flipY: false}); +``` + +All that's left to do is change our texture's view in the bindGroup + +```js + const bindGroup = device.createBindGroup({ + label: 'bind group for object', + layout: pipeline.getBindGroupLayout(0), + entries: [ + { binding: 0, resource: { buffer: uniformBuffer }}, + { binding: 1, resource: sampler }, +- { binding: 2, resource: texture.createView() }, ++ { binding: 2, resource: texture.createView({dimension: 'cube'}) }, + ], + }); +``` + +And poof + +{{{example url="../webgpu-cube-map.html" }}} + +Using a cubemap to texture a cube is **not** what cubemaps are normally +used for. The *correct* or rather standard way to texture a cube is +to use a texture atlas like we [mentioned before](webgpu-importing-textures.html#a-texture-atlases). +The point of this article was to introduce the concept of cube map and show how you pass it +directions (normals) and it returns the color of the cube in that direction. + +Now that we've learned what a cubemap is and how to set one up what is a cubemap +used for? Probably the single most common thing a cubemap is used for is as an +[*environment map*](webgpu-environment-maps.html). + diff --git a/webgpu/lessons/webgpu-importing-textures.js b/webgpu/lessons/webgpu-importing-textures.js new file mode 100644 index 00000000..f22feadd --- /dev/null +++ b/webgpu/lessons/webgpu-importing-textures.js @@ -0,0 +1,70 @@ +import { + renderDiagrams +} from './resources/diagrams.js'; +import { SVG as svg } from '/3rdparty/svg.esm.js'; +import { + createElem as el, +} from './resources/elem.js'; + +const makeText = (parent, t) => { + return parent.text(t) + .font({ + family: 'monospace', + weight: 'bold', + size: '14', + }) + .css({ + filter: ` + drop-shadow( 1px 0px 0px #fff) + drop-shadow( 0px 1px 0px #fff) + drop-shadow(-1px 0px 0px #fff) + drop-shadow( 0px -1px 0px #fff) + `, + }); +}; + +function showTextureCoords(elem, zeroZeroBottomLeft) { + const diagramDiv = el('div'); + const uiDiv = el('div'); + const div = el('div', {}, [diagramDiv, uiDiv]); + elem.appendChild(div); + const hEdge = 100; + const vEdge = 50; + const size = 100; + const w = size * 4; + const h = size * 2; + const draw = svg().addTo(diagramDiv).viewbox(0, 0, w + hEdge * 2, h + vEdge * 2); + draw + .image('/webgpu/resources/images/noodles.jpg') + .move(hEdge, vEdge) + .size(w, h) + .transform({scale: zeroZeroBottomLeft ? [1, -1] : [1, 1]}); + + for (let lx = 0; lx < 5; ++lx) { + const x = hEdge + lx * size; + draw.line(x , vEdge / 2, x, vEdge + h + vEdge / 2).stroke('white'); + makeText(draw, (lx / 4)) + .transform({ + translate: [ + x, + zeroZeroBottomLeft ? vEdge + h + vEdge / 5 * 4 : vEdge / 3, + ], + }) + .font({anchor: 'middle'}); + } + + for (let ly = 0; ly < 3; ++ly) { + const y = vEdge + ly * size; + draw.line(hEdge - vEdge, y, hEdge + w + vEdge / 2, y).stroke('white'); + makeText(draw, (zeroZeroBottomLeft ? (1 - ly / 2) : ly / 2)).transform({translate: [hEdge / 3, y]}).font({anchor: 'middle', 'dominant-baseline': 'middle'}); + } +} + +renderDiagrams({ + 'texture-atlas': (elem) => { + showTextureCoords(elem, false); + }, + 'texture-atlas-bottom-left': (elem) => { + showTextureCoords(elem, true); + }, +}); diff --git a/webgpu/lessons/webgpu-importing-textures.md b/webgpu/lessons/webgpu-importing-textures.md index 9ca990df..e26d3b54 100644 --- a/webgpu/lessons/webgpu-importing-textures.md +++ b/webgpu/lessons/webgpu-importing-textures.md @@ -815,7 +815,7 @@ For example With this change we'd only update the video for each new frame. So, for example, on a device with a display rate of 120 frames per second we'd draw at 120 frames per second so animations, -camera movements, etc would be smooth. But, the texture would only update at its own frame +camera movements, etc would be smooth. But, the video texture itself would only update at its own frame rate (for example 30fps). **BUT! WebGPU has special support for using video efficiently** @@ -828,5 +828,375 @@ copied, **per frame**. [External textures](webgpu-textures-external-video.html) let you use the video's data directly (no copy) but require different methods and have some restrictions. -TBD: Atlas +## Texture Atlases +From the examples above, we can see that to draw something with a texture +we have to create the texture, put data it in, bind it to bindGroup with +a sampler, +and reference it from a shader. So what would we do if we wanted +to draw multiple different textures on an object? Say we had a chair where the legs and back +are made of wood but the cushion is made of cloth. + +
+
+ +
+
+ "[CC0] Chair" by adadadad5252341 CC-BY 4.0 +
+
+ +Or a car where the tires are rubber, the body is paint, the bumpers and hub caps +are chrome. + +
+
+ +
+
+ "Classic Muscle car" by Lexyc16 CC-BY 4.0 +
+
+ +If we did nothing else you might think we'd have to draw 2 times for +the chair, once for the wood with a wood texture, and once for the +cushion with a cloth texture. For the car we'd have several draws, one for +the tires, one for the body, one for the bumpers, etc... + +That would end up being slow as every object would require multiple +draw calls. We could try to fix that by adding more inputs to our +shader (2, 3, 4 textures) with texture coordinates for each one +but that would not be very flexible and would be slow as well +as we'd need to read all 4 textures and add code to chose between them. + +The most common way to cover this case is to use what's called a +[Texture Atlas](https://www.google.com/search?q=texture+atlas). +A Texture Atlas is a fancy name for a texture with +multiple images it in. We then use texture coordinates to select +which parts go where. + +Let's wrap a cube with these 6 images + +
+ + + + + +
+
+ +Using some image editing software like Photoshop or [Photopea](https://photopea.com) we could put all 6 images into a single image + + + +We'd then make a cube and provide texture coordinates that select each +portion of the image onto a specific face of the cube. To keep it simple I put +all 6 images in the texture above in squares, 4x2. So it should be pretty +easy to compute the texture coordinates for each square. + +
+
+
+
+
+ +> The diagram above might be confusing because it is often suggested that texture coordinates +> have 0,0 as the bottom left corner. Really though there is no "bottom". There is just the idea +> that texture coordinate 0,0 references the first pixel in the texture's data. The first +> pixel in the texture's data is the top left corner of the image. +> If you subscribe to the idea that 0,0 = bottom left then our texture coordinates +> would be visualized like this. **They're still the same coordinates**. + +
+
+
+
0,0 at bottom left
+
+
+ + +Here's the position vertices for a cube and the texture coordinates +to go with them + +```js +function createCubeVertices() { + const vertexData = new Float32Array([ + // position | texture coordinate + //-------------+---------------------- + // front face select the top left image + -1, 1, 1, 0 , 0 , + -1, -1, 1, 0 , 0.5, + 1, 1, 1, 0.25, 0 , + 1, -1, 1, 0.25, 0.5, + // right face select the top middle image + 1, 1, -1, 0.25, 0 , + 1, 1, 1, 0.5 , 0 , + 1, -1, -1, 0.25, 0.5, + 1, -1, 1, 0.5 , 0.5, + // back face select to top right image + 1, 1, -1, 0.5 , 0 , + 1, -1, -1, 0.5 , 0.5, + -1, 1, -1, 0.75, 0 , + -1, -1, -1, 0.75, 0.5, + // left face select the bottom left image + -1, 1, 1, 0 , 0.5, + -1, 1, -1, 0.25, 0.5, + -1, -1, 1, 0 , 1 , + -1, -1, -1, 0.25, 1 , + // bottom face select the bottom middle image + 1, -1, 1, 0.25, 0.5, + -1, -1, 1, 0.5 , 0.5, + 1, -1, -1, 0.25, 1 , + -1, -1, -1, 0.5 , 1 , + // top face select the bottom right image + -1, 1, 1, 0.5 , 0.5, + 1, 1, 1, 0.75, 0.5, + -1, 1, -1, 0.5 , 1 , + 1, 1, -1, 0.75, 1 , + + ]); + + const indexData = new Uint16Array([ + 0, 1, 2, 2, 1, 3, // front + 4, 5, 6, 6, 5, 7, // right + 8, 9, 10, 10, 9, 11, // back + 12, 13, 14, 14, 13, 15, // left + 16, 17, 18, 18, 17, 19, // bottom + 20, 21, 22, 22, 21, 23, // top + ]); + + return { + vertexData, + indexData, + numVertices: indexData.length, + }; +} +``` + +To make this example we're going to have start with an example from [the article on cameras](webgpu-cameras.html). +If you haven't read the article yet you can read it and the series it's a part of the learn how do 3D. +For now, the important part is, like we did above, we output positions and texture coordinates from our +vertex shader and use them to look up values from a texture in our fragment shader. So, here's +the changes needed from the shader in the camera example, applying what we have above. + +```wgsl +struct Uniforms { + matrix: mat4x4f, +}; + +struct Vertex { + @location(0) position: vec4f, +- @location(1) color: vec4f, ++ @location(1) texcoord: vec2f, +}; + +struct VSOutput { + @builtin(position) position: vec4f, +- @location(0) color: vec4f, ++ @location(0) texcoord: vec2f, +}; + +@group(0) @binding(0) var uni: Uniforms; ++@group(0) @binding(1) var ourSampler: sampler; ++@group(0) @binding(2) var ourTexture: texture_2d; + +@vertex fn vs(vert: Vertex) -> VSOutput { + var vsOut: VSOutput; + vsOut.position = uni.matrix * vert.position; +- vsOut.color = vert.color; ++ vsOut.texcoord = vert.texcoord; + return vsOut; +} + +@fragment fn fs(vsOut: VSOutput) -> @location(0) vec4f { +- return vsOut.color; ++ return textureSample(ourTexture, ourSampler, vsOut.texcoord); +} +``` + +All we did was switch from taking a color per vertex to a texture coordinate per vertex +and passing that texture coordinate to the fragment shader, like we did above. We then +use it, in the fragment shader, like we did above. + +In JavaScript we need to change that example's pipeline from taking a color to taking +texture coordinates + +```js + const pipeline = device.createRenderPipeline({ + label: '2 attributes', + layout: 'auto', + vertex: { + module, + entryPoint: 'vs', + buffers: [ + { +- arrayStride: (4) * 4, // (3) floats 4 bytes each + one 4 byte color ++ arrayStride: (3 + 2) * 4, // (3+2) floats 4 bytes each + attributes: [ + {shaderLocation: 0, offset: 0, format: 'float32x3'}, // position +- {shaderLocation: 1, offset: 12, format: 'unorm8x4'}, // color ++ {shaderLocation: 1, offset: 12, format: 'float32x2'}, // texcoord + ], + }, + ], + }, + fragment: { + module, + entryPoint: 'fs', + targets: [{ format: presentationFormat }], + }, + primitive: { + cullMode: 'back', + }, + depthStencil: { + depthWriteEnabled: true, + depthCompare: 'less', + format: 'depth24plus', + }, + }); +``` + +To keep the data smaller we're going to use a indices like we covered in [the article on vertex buffers](webgpu-vertex-buffers.html). + +```js +- const { vertexData, numVertices } = createFVertices(); ++ const { vertexData, indexData, numVertices } = createCubeVertices(); + const vertexBuffer = device.createBuffer({ + label: 'vertex buffer vertices', + size: vertexData.byteLength, + usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST, + }); + device.queue.writeBuffer(vertexBuffer, 0, vertexData); + ++ const indexBuffer = device.createBuffer({ ++ label: 'index buffer', ++ size: vertexData.byteLength, ++ usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST, ++ }); ++ device.queue.writeBuffer(indexBuffer, 0, indexData); +``` + +We need to copy all of the texture loading and mip generation code into this example +and then use it to load the texture atlas image. We also need to make a sampler +and add them our bindGroup + +```js ++ const texture = await createTextureFromImage(device, ++ 'resources/images/noodles.jpg', {mips: true, flipY: false}); ++ ++ const sampler = device.createSampler({ ++ magFilter: 'linear', ++ minFilter: 'linear', ++ mipmapFilter: 'linear', ++ }); + + const bindGroup = device.createBindGroup({ + label: 'bind group for object', + layout: pipeline.getBindGroupLayout(0), + entries: [ + { binding: 0, resource: { buffer: uniformBuffer }}, ++ { binding: 1, resource: sampler }, ++ { binding: 2, resource: texture.createView() }, + ], + }); +``` + +We need to do some 3D math to setup a matrix for drawing in 3D. (Again, see [the camera article](webgpu-cameras.html) for +details on 3D math. + +```js + const degToRad = d => d * Math.PI / 180; + + const settings = { + rotation: [degToRad(20), degToRad(25), degToRad(0)], + }; + + const radToDegOptions = { min: -360, max: 360, step: 1, converters: GUI.converters.radToDeg }; + + const gui = new GUI(); + gui.onChange(render); + gui.add(settings.rotation, '0', radToDegOptions).name('rotation.x'); + gui.add(settings.rotation, '1', radToDegOptions).name('rotation.y'); + gui.add(settings.rotation, '2', radToDegOptions).name('rotation.z'); + + ... + + function render() { + + ... + + const aspect = canvas.clientWidth / canvas.clientHeight; + mat4.perspective( + 60 * Math.PI / 180, + aspect, + 0.1, // zNear + 10, // zFar + matrixValue, + ); + const view = mat4.lookAt( + [0, 1, 5], // camera position + [0, 0, 0], // target + [0, 1, 0], // up + ); + mat4.multiply(matrixValue, view, matrixValue); + mat4.rotateX(matrixValue, settings.rotation[0], matrixValue); + mat4.rotateY(matrixValue, settings.rotation[1], matrixValue); + mat4.rotateZ(matrixValue, settings.rotation[2], matrixValue); + + // upload the uniform values to the uniform buffer + device.queue.writeBuffer(uniformBuffer, 0, uniformValues); +``` + +And at render time we need to draw with indices + +```js + const encoder = device.createCommandEncoder(); + const pass = encoder.beginRenderPass(renderPassDescriptor); + pass.setPipeline(pipeline); + pass.setVertexBuffer(0, vertexBuffer); ++ pass.setIndexBuffer(indexBuffer, 'uint16'); + + ... + + pass.setBindGroup(0, bindGroup); +- pass.draw(numVertices); ++ pass.drawIndexed(numVertices); + + pass.end(); +``` + +And we that we get a cube, with a different image on each side, using a single texture. + +{{{example url="../webgpu-texture-atlas.html"}}} + +Using a texture atlas is good because there's just 1 texture to load, the shader stays simple as it only has to reference 1 texture, and it only +requires 1 draw call to draw the shape instead of 1 draw call per texture as it might if we keep the images separate. + + + + diff --git a/webgpu/lessons/webgpu-typedarrays.md b/webgpu/lessons/webgpu-typedarrays.md deleted file mode 100644 index e1b3d90e..00000000 --- a/webgpu/lessons/webgpu-typedarrays.md +++ /dev/null @@ -1,6 +0,0 @@ -Title: WebGPU TypedArrays -Description: Using TypedArrays -TOC: TypedArrays - -TBD - diff --git a/webgpu/resources/images/noodles.jpg b/webgpu/resources/images/noodles.jpg new file mode 100644 index 00000000..d98dfe8a Binary files /dev/null and b/webgpu/resources/images/noodles.jpg differ diff --git a/webgpu/resources/models/gltf/cc0_chair.glb b/webgpu/resources/models/gltf/cc0_chair.glb new file mode 100644 index 00000000..9ec59807 Binary files /dev/null and b/webgpu/resources/models/gltf/cc0_chair.glb differ diff --git a/webgpu/resources/models/gltf/cco_chair.txt b/webgpu/resources/models/gltf/cco_chair.txt new file mode 100644 index 00000000..27e71b29 --- /dev/null +++ b/webgpu/resources/models/gltf/cco_chair.txt @@ -0,0 +1 @@ +"[CC0] Chair" (https://skfb.ly/opnwY) by adadadad5252341 is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/). diff --git a/webgpu/resources/models/gltf/classic_muscle_car.glb b/webgpu/resources/models/gltf/classic_muscle_car.glb new file mode 100644 index 00000000..b033c564 Binary files /dev/null and b/webgpu/resources/models/gltf/classic_muscle_car.glb differ diff --git a/webgpu/resources/models/gltf/classic_muscle_car.txt b/webgpu/resources/models/gltf/classic_muscle_car.txt new file mode 100644 index 00000000..d250db6f --- /dev/null +++ b/webgpu/resources/models/gltf/classic_muscle_car.txt @@ -0,0 +1 @@ +"Classic Muscle car" (https://skfb.ly/6Usqo) by Lexyc16 is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/). diff --git a/webgpu/webgpu-cube-faces.html b/webgpu/webgpu-cube-faces.html new file mode 100644 index 00000000..f263de2f --- /dev/null +++ b/webgpu/webgpu-cube-faces.html @@ -0,0 +1,45 @@ + + + + WebGPU Textured Cube Map + + + + + + diff --git a/webgpu/webgpu-cube-map.html b/webgpu/webgpu-cube-map.html new file mode 100644 index 00000000..6e023c96 --- /dev/null +++ b/webgpu/webgpu-cube-map.html @@ -0,0 +1,501 @@ + + + + WebGPU Textured Cube Map + + + + + + + diff --git a/webgpu/webgpu-cube-mutiple.html b/webgpu/webgpu-cube-mutiple.html deleted file mode 100644 index 28a0991f..00000000 --- a/webgpu/webgpu-cube-mutiple.html +++ /dev/null @@ -1,344 +0,0 @@ - - - - WebGPU Cube Multiple - - - - - - - - \ No newline at end of file diff --git a/webgpu/webgpu-texture-atlas.html b/webgpu/webgpu-texture-atlas.html new file mode 100644 index 00000000..f9cbec6d --- /dev/null +++ b/webgpu/webgpu-texture-atlas.html @@ -0,0 +1,839 @@ + + + + WebGPU Perspective - Matrix Z to W - Step 3 + + + + +
+ + +