/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
const i$2=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(i){i.createProperty(t.key,e)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(i){i.createProperty(t.key,e)}};function n$8(e){return(t,i)=>void 0!==i?((e,t,i)=>{t.constructor.createProperty(i,e)})(e,t,i):i$2(e,t)}
/**
 * @license
 * Copyright 2021 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */var e;null===(e=window.HTMLSlotElement)||void 0===e||e.prototype.assignedElements;
/**
 * @license
 * Copyright 2010-2023 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const t="154",i=0,n=1,r=2,a=100,o=101,l=102,c=200,h=201,d=202,A=203,p=204,m=205,g=206,f=207,v=208,E=209,y=210,_=301,x=302,S=303,C=306,b=1e3,I=1001,T=1002,B=1003,U=1004,F=1005,O=1006,G=1007,W=1008,q=1009,X=1012,j=1013,Y=1014,K=1015,$=1016,J=1020,ee=1023,te=1026,ie=1027,ne=1028,re=1030,se=33776,ae=33777,oe=33778,le=33779,ce=35840,he=35842,ue=37492,de=37496,Ae=37808,pe=36492,me=2201,ge=2202,fe=2300,ve=2301,Ee=2302,ye=2400,_e=2401,xe=2402,Se=2500,Ce=3001,Me="",be="srgb",Ie="srgb-linear",we="display-p3",Te=7680,Be=512,Re=513,Le=514,De=515,Ue=516,Pe=517,Fe=518,Ne=519,Qe=35044,Oe="300 es",ke=1035,Ge=2e3,Ve=2001;class EventDispatcher{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const i=this._listeners[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const i=t.slice(0);for(let t=0,n=i.length;t<n;t++)i[t].call(this,e);e.target=null}}}const He=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let ze=1234567;const We=Math.PI/180,qe=180/Math.PI;function generateUUID(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(He[255&e]+He[e>>8&255]+He[e>>16&255]+He[e>>24&255]+"-"+He[255&t]+He[t>>8&255]+"-"+He[t>>16&15|64]+He[t>>24&255]+"-"+He[63&i|128]+He[i>>8&255]+"-"+He[i>>16&255]+He[i>>24&255]+He[255&n]+He[n>>8&255]+He[n>>16&255]+He[n>>24&255]).toLowerCase()}function clamp$1(e,t,i){return Math.max(t,Math.min(i,e))}function euclideanModulo(e,t){return(e%t+t)%t}function lerp$1(e,t,i){return(1-i)*e+i*t}function isPowerOfTwo(e){return!(e&e-1)&&0!==e}function ceilPowerOfTwo(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function floorPowerOfTwo(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function denormalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function normalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Xe={DEG2RAD:We,RAD2DEG:qe,generateUUID,clamp:clamp$1,euclideanModulo,mapLinear:function mapLinear(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)},inverseLerp:function inverseLerp(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:lerp$1,damp:function damp(e,t,i,n){return lerp$1(e,t,1-Math.exp(-i*n))},pingpong:function pingpong(e,t=1){return t-Math.abs(euclideanModulo(e,2*t)-t)},smoothstep:function smoothstep(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function smootherstep(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function randInt(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function randFloat(e,t){return e+Math.random()*(t-e)},randFloatSpread:function randFloatSpread(e){return e*(.5-Math.random())},seededRandom:function seededRandom(e){void 0!==e&&(ze=e);let t=ze+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function degToRad(e){return e*We},radToDeg:function radToDeg(e){return e*qe},isPowerOfTwo,ceilPowerOfTwo,floorPowerOfTwo,setQuaternionFromProperEuler:function setQuaternionFromProperEuler(e,t,i,n,r){const a=Math.cos,o=Math.sin,l=a(i/2),c=o(i/2),h=a((t+n)/2),d=o((t+n)/2),A=a((t-n)/2),p=o((t-n)/2),m=a((n-t)/2),g=o((n-t)/2);switch(r){case"XYX":e.set(l*d,c*A,c*p,l*h);break;case"YZY":e.set(c*p,l*d,c*A,l*h);break;case"ZXZ":e.set(c*A,c*p,l*d,l*h);break;case"XZX":e.set(l*d,c*g,c*m,l*h);break;case"YXY":e.set(c*m,l*d,c*g,l*h);break;case"ZYZ":e.set(c*g,c*m,l*d,l*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize,denormalize};class Vector2{constructor(e=0,t=0){Vector2.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(clamp$1(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*n+e.x,this.y=r*n+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Matrix3{constructor(e,t,i,n,r,a,o,l,c){Matrix3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,i,n,r,a,o,l,c)}set(e,t,i,n,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=n,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=i,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],d=i[7],A=i[2],p=i[5],m=i[8],g=n[0],f=n[3],v=n[6],E=n[1],y=n[4],_=n[7],x=n[2],S=n[5],C=n[8];return r[0]=a*g+o*E+l*x,r[3]=a*f+o*y+l*S,r[6]=a*v+o*_+l*C,r[1]=c*g+h*E+d*x,r[4]=c*f+h*y+d*S,r[7]=c*v+h*_+d*C,r[2]=A*g+p*E+m*x,r[5]=A*f+p*y+m*S,r[8]=A*v+p*_+m*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-i*r*h+i*o*l+n*r*c-n*a*l}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,A=o*l-h*r,p=c*r-a*l,m=t*d+i*A+n*p;if(0===m)return this.set(0,0,0,0,0,0,0,0,0);const g=1/m;return e[0]=d*g,e[1]=(n*c-h*i)*g,e[2]=(o*i-n*a)*g,e[3]=A*g,e[4]=(h*t-n*l)*g,e[5]=(n*r-o*t)*g,e[6]=p*g,e[7]=(i*l-c*t)*g,e[8]=(a*t-i*r)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,n,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-n*c,n*l,-n*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(je.makeScale(e,t)),this}rotate(e){return this.premultiply(je.makeRotation(-e)),this}translate(e,t){return this.premultiply(je.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const je=new Matrix3;function arrayNeedsUint32(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const Ye={};function warnOnce(e){e in Ye||(Ye[e]=!0,console.warn(e))}function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function LinearToSRGB(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const Ke=(new Matrix3).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),$e=(new Matrix3).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);const Je={[Ie]:e=>e,[be]:e=>e.convertSRGBToLinear(),[we]:function DisplayP3ToLinearSRGB(e){return e.convertSRGBToLinear().applyMatrix3($e)}},Ze={[Ie]:e=>e,[be]:e=>e.convertLinearToSRGB(),[we]:function LinearSRGBToDisplayP3(e){return e.applyMatrix3(Ke).convertLinearToSRGB()}},et={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return Ie},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,i){if(!1===this.enabled||t===i||!t||!i)return e;const n=Je[t],r=Ze[i];if(void 0===n||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${i}".`);return r(n(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let tt;class ImageUtils{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===tt&&(tt=createElementNS("canvas")),tt.width=e.width,tt.height=e.height;const i=tt.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=tt}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=createElementNS("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let e=0;e<r.length;e++)r[e]=255*SRGBToLinear(r[e]/255);return i.putImageData(n,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*SRGBToLinear(t[e]/255)):t[e]=SRGBToLinear(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let it=0;class Source{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:it++}),this.uuid=generateUUID(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let e;if(Array.isArray(n)){e=[];for(let t=0,i=n.length;t<i;t++)n[t].isDataTexture?e.push(serializeImage(n[t].image)):e.push(serializeImage(n[t]))}else e=serializeImage(n);i.url=e}return t||(e.images[this.uuid]=i),i}}function serializeImage(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ImageUtils.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let nt=0;class Texture$1 extends EventDispatcher{constructor(e=Texture$1.DEFAULT_IMAGE,t=Texture$1.DEFAULT_MAPPING,i=1001,n=1001,r=1006,a=1008,o=1023,l=1009,c=Texture$1.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:nt++}),this.uuid=generateUUID(),this.name="",this.source=new Source(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Vector2(0,0),this.repeat=new Vector2(1,1),this.center=new Vector2(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Matrix3,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Ce?be:Me),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case b:e.x=e.x-Math.floor(e.x);break;case I:e.x=e.x<0?0:1;break;case T:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case b:e.y=e.y-Math.floor(e.y);break;case I:e.y=e.y<0?0:1;break;case T:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===be?Ce:3e3}set encoding(e){warnOnce("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ce?be:Me}}Texture$1.DEFAULT_IMAGE=null,Texture$1.DEFAULT_MAPPING=300,Texture$1.DEFAULT_ANISOTROPY=1;class Vector4{constructor(e=0,t=0,i=0,n=1){Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*n+a[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,n,r;const a=.01,o=.1,l=e.elements,c=l[0],h=l[4],d=l[8],A=l[1],p=l[5],m=l[9],g=l[2],f=l[6],v=l[10];if(Math.abs(h-A)<a&&Math.abs(d-g)<a&&Math.abs(m-f)<a){if(Math.abs(h+A)<o&&Math.abs(d+g)<o&&Math.abs(m+f)<o&&Math.abs(c+p+v-3)<o)return this.set(1,0,0,0),this;t=Math.PI;const e=(c+1)/2,l=(p+1)/2,E=(v+1)/2,y=(h+A)/4,_=(d+g)/4,x=(m+f)/4;return e>l&&e>E?e<a?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(e),n=y/i,r=_/i):l>E?l<a?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(l),i=y/n,r=x/n):E<a?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(E),i=_/r,n=x/r),this.set(i,n,r,t),this}let E=Math.sqrt((f-m)*(f-m)+(d-g)*(d-g)+(A-h)*(A-h));return Math.abs(E)<.001&&(E=1),this.x=(f-m)/E,this.y=(d-g)/E,this.z=(A-h)/E,this.w=Math.acos((c+p+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class WebGLRenderTarget extends EventDispatcher{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Vector4(0,0,e,t),this.scissorTest=!1,this.viewport=new Vector4(0,0,e,t);const n={width:e,height:t,depth:1};void 0!==i.encoding&&(warnOnce("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Ce?be:Me),this.texture=new Texture$1(n,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:O,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null,this.samples=void 0!==i.samples?i.samples:0}setSize(e,t,i=1){this.width===e&&this.height===t&&this.depth===i||(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Source(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class DataArrayTexture extends Texture$1{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=B,this.minFilter=B,this.wrapR=I,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Data3DTexture extends Texture$1{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=B,this.minFilter=B,this.wrapR=I,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Quaternion{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,r,a,o){let l=i[n+0],c=i[n+1],h=i[n+2],d=i[n+3];const A=r[a+0],p=r[a+1],m=r[a+2],g=r[a+3];if(0===o)return e[t+0]=l,e[t+1]=c,e[t+2]=h,void(e[t+3]=d);if(1===o)return e[t+0]=A,e[t+1]=p,e[t+2]=m,void(e[t+3]=g);if(d!==g||l!==A||c!==p||h!==m){let e=1-o;const t=l*A+c*p+h*m+d*g,i=t>=0?1:-1,n=1-t*t;if(n>Number.EPSILON){const r=Math.sqrt(n),a=Math.atan2(r,t*i);e=Math.sin(e*a)/r,o=Math.sin(o*a)/r}const r=o*i;if(l=l*e+A*r,c=c*e+p*r,h=h*e+m*r,d=d*e+g*r,e===1-o){const e=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=e,c*=e,h*=e,d*=e}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,n,r,a){const o=i[n],l=i[n+1],c=i[n+2],h=i[n+3],d=r[a],A=r[a+1],p=r[a+2],m=r[a+3];return e[t]=o*m+h*d+l*p-c*A,e[t+1]=l*m+h*A+c*d-o*p,e[t+2]=c*m+h*p+o*A-l*d,e[t+3]=h*m-o*d-l*A-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const i=e._x,n=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(n/2),d=o(r/2),A=l(i/2),p=l(n/2),m=l(r/2);switch(a){case"XYZ":this._x=A*h*d+c*p*m,this._y=c*p*d-A*h*m,this._z=c*h*m+A*p*d,this._w=c*h*d-A*p*m;break;case"YXZ":this._x=A*h*d+c*p*m,this._y=c*p*d-A*h*m,this._z=c*h*m-A*p*d,this._w=c*h*d+A*p*m;break;case"ZXY":this._x=A*h*d-c*p*m,this._y=c*p*d+A*h*m,this._z=c*h*m+A*p*d,this._w=c*h*d-A*p*m;break;case"ZYX":this._x=A*h*d-c*p*m,this._y=c*p*d+A*h*m,this._z=c*h*m-A*p*d,this._w=c*h*d+A*p*m;break;case"YZX":this._x=A*h*d+c*p*m,this._y=c*p*d+A*h*m,this._z=c*h*m-A*p*d,this._w=c*h*d-A*p*m;break;case"XZY":this._x=A*h*d-c*p*m,this._y=c*p*d-A*h*m,this._z=c*h*m+A*p*d,this._w=c*h*d+A*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],n=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],d=t[10],A=i+o+d;if(A>0){const e=.5/Math.sqrt(A+1);this._w=.25/e,this._x=(h-l)*e,this._y=(r-c)*e,this._z=(a-n)*e}else if(i>o&&i>d){const e=2*Math.sqrt(1+i-o-d);this._w=(h-l)/e,this._x=.25*e,this._y=(n+a)/e,this._z=(r+c)/e}else if(o>d){const e=2*Math.sqrt(1+o-i-d);this._w=(r-c)/e,this._x=(n+a)/e,this._y=.25*e,this._z=(l+h)/e}else{const e=2*Math.sqrt(1+d-i-o);this._w=(a-n)/e,this._x=(r+c)/e,this._y=(l+h)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(clamp$1(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(0===i)return this;const n=Math.min(1,t/i);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,n=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=i*h+a*o+n*c-r*l,this._y=n*h+a*l+r*o-i*c,this._z=r*h+a*c+i*l-n*o,this._w=a*h-i*o-n*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const i=this._x,n=this._y,r=this._z,a=this._w;let o=a*e._w+i*e._x+n*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=n,this._z=r,this;const l=1-o*o;if(l<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*i+t*this._x,this._y=e*n+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),d=Math.sin((1-t)*h)/c,A=Math.sin(t*h)/c;return this._w=a*d+this._w*A,this._x=i*d+this._x*A,this._y=n*d+this._y*A,this._z=r*d+this._z*A,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(n),i*Math.sin(r),i*Math.cos(r),t*Math.sin(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Vector3{constructor(e=0,t=0,i=0){Vector3.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(st.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(st.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,n=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,n=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=l*t+a*n-o*i,h=l*i+o*t-r*n,d=l*n+r*i-a*t,A=-r*t-a*i-o*n;return this.x=c*l+A*-r+h*-o-d*-a,this.y=h*l+A*-a+d*-r-c*-o,this.z=d*l+A*-o+c*-a-h*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,n=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=n*l-r*o,this.y=r*a-i*l,this.z=i*o-n*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return rt.copy(this).projectOnVector(e),this.sub(rt)}reflect(e){return this.sub(rt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(clamp$1(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const rt=new Vector3,st=new Quaternion;class Box3{constructor(e=new Vector3(1/0,1/0,1/0),t=new Vector3(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(ot.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(ot.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=ot.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),void 0!==e.boundingBox)null===e.boundingBox&&e.computeBoundingBox(),lt.copy(e.boundingBox),lt.applyMatrix4(e.matrixWorld),this.union(lt);else{const i=e.geometry;if(void 0!==i)if(t&&void 0!==i.attributes&&void 0!==i.attributes.position){const t=i.attributes.position;for(let i=0,n=t.count;i<n;i++)ot.fromBufferAttribute(t,i).applyMatrix4(e.matrixWorld),this.expandByPoint(ot)}else null===i.boundingBox&&i.computeBoundingBox(),lt.copy(i.boundingBox),lt.applyMatrix4(e.matrixWorld),this.union(lt)}const i=e.children;for(let e=0,n=i.length;e<n;e++)this.expandByObject(i[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,ot),ot.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(mt),gt.subVectors(this.max,mt),ct.subVectors(e.a,mt),ht.subVectors(e.b,mt),ut.subVectors(e.c,mt),dt.subVectors(ht,ct),At.subVectors(ut,ht),pt.subVectors(ct,ut);let t=[0,-dt.z,dt.y,0,-At.z,At.y,0,-pt.z,pt.y,dt.z,0,-dt.x,At.z,0,-At.x,pt.z,0,-pt.x,-dt.y,dt.x,0,-At.y,At.x,0,-pt.y,pt.x,0];return!!satForAxes(t,ct,ht,ut,gt)&&(t=[1,0,0,0,1,0,0,0,1],!!satForAxes(t,ct,ht,ut,gt)&&(ft.crossVectors(dt,At),t=[ft.x,ft.y,ft.z],satForAxes(t,ct,ht,ut,gt)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ot).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(ot).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(at[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),at[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),at[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),at[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),at[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),at[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),at[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),at[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(at)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const at=[new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3,new Vector3],ot=new Vector3,lt=new Box3,ct=new Vector3,ht=new Vector3,ut=new Vector3,dt=new Vector3,At=new Vector3,pt=new Vector3,mt=new Vector3,gt=new Vector3,ft=new Vector3,vt=new Vector3;function satForAxes(e,t,i,n,r){for(let a=0,o=e.length-3;a<=o;a+=3){vt.fromArray(e,a);const o=r.x*Math.abs(vt.x)+r.y*Math.abs(vt.y)+r.z*Math.abs(vt.z),l=t.dot(vt),c=i.dot(vt),h=n.dot(vt);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Et=new Box3,yt=new Vector3,_t=new Vector3;class Sphere{constructor(e=new Vector3,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const i=this.center;void 0!==t?i.copy(t):Et.setFromPoints(e).getCenter(i);let n=0;for(let t=0,r=e.length;t<r;t++)n=Math.max(n,i.distanceToSquared(e[t]));return this.radius=Math.sqrt(n),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;yt.subVectors(e,this.center);const t=yt.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),i=.5*(e-this.radius);this.center.addScaledVector(yt,i/e),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(_t.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yt.copy(e.center).add(_t)),this.expandByPoint(yt.copy(e.center).sub(_t))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const xt=new Vector3,St=new Vector3,Ct=new Vector3,Mt=new Vector3,bt=new Vector3,It=new Vector3,wt=new Vector3;class Ray{constructor(e=new Vector3,t=new Vector3(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,xt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=xt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(xt.copy(this.origin).addScaledVector(this.direction,t),xt.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){St.copy(e).add(t).multiplyScalar(.5),Ct.copy(t).sub(e).normalize(),Mt.copy(this.origin).sub(St);const r=.5*e.distanceTo(t),a=-this.direction.dot(Ct),o=Mt.dot(this.direction),l=-Mt.dot(Ct),c=Mt.lengthSq(),h=Math.abs(1-a*a);let d,A,p,m;if(h>0)if(d=a*l-o,A=a*o-l,m=r*h,d>=0)if(A>=-m)if(A<=m){const e=1/h;d*=e,A*=e,p=d*(d+a*A+2*o)+A*(a*d+A+2*l)+c}else A=r,d=Math.max(0,-(a*A+o)),p=-d*d+A*(A+2*l)+c;else A=-r,d=Math.max(0,-(a*A+o)),p=-d*d+A*(A+2*l)+c;else A<=-m?(d=Math.max(0,-(-a*r+o)),A=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+A*(A+2*l)+c):A<=m?(d=0,A=Math.min(Math.max(-r,-l),r),p=A*(A+2*l)+c):(d=Math.max(0,-(a*r+o)),A=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+A*(A+2*l)+c);else A=a>0?-r:r,d=Math.max(0,-(a*A+o)),p=-d*d+A*(A+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),n&&n.copy(St).addScaledVector(Ct,A),p}intersectSphere(e,t){xt.subVectors(e.center,this.origin);const i=xt.dot(this.direction),n=xt.dot(xt)-i*i,r=e.radius*e.radius;if(n>r)return null;const a=Math.sqrt(r-n),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,A=this.origin;return c>=0?(i=(e.min.x-A.x)*c,n=(e.max.x-A.x)*c):(i=(e.max.x-A.x)*c,n=(e.min.x-A.x)*c),h>=0?(r=(e.min.y-A.y)*h,a=(e.max.y-A.y)*h):(r=(e.max.y-A.y)*h,a=(e.min.y-A.y)*h),i>a||r>n?null:((r>i||isNaN(i))&&(i=r),(a<n||isNaN(n))&&(n=a),d>=0?(o=(e.min.z-A.z)*d,l=(e.max.z-A.z)*d):(o=(e.max.z-A.z)*d,l=(e.min.z-A.z)*d),i>l||o>n?null:((o>i||i!=i)&&(i=o),(l<n||n!=n)&&(n=l),n<0?null:this.at(i>=0?i:n,t)))}intersectsBox(e){return null!==this.intersectBox(e,xt)}intersectTriangle(e,t,i,n,r){bt.subVectors(t,e),It.subVectors(i,e),wt.crossVectors(bt,It);let a,o=this.direction.dot(wt);if(o>0){if(n)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Mt.subVectors(this.origin,e);const l=a*this.direction.dot(It.crossVectors(Mt,It));if(l<0)return null;const c=a*this.direction.dot(bt.cross(Mt));if(c<0)return null;if(l+c>o)return null;const h=-a*Mt.dot(wt);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Matrix4{constructor(e,t,i,n,r,a,o,l,c,h,d,A,p,m,g,f){Matrix4.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,i,n,r,a,o,l,c,h,d,A,p,m,g,f)}set(e,t,i,n,r,a,o,l,c,h,d,A,p,m,g,f){const v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=n,v[1]=r,v[5]=a,v[9]=o,v[13]=l,v[2]=c,v[6]=h,v[10]=d,v[14]=A,v[3]=p,v[7]=m,v[11]=g,v[15]=f,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 Matrix4).fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,n=1/Tt.setFromMatrixColumn(e,0).length(),r=1/Tt.setFromMatrixColumn(e,1).length(),a=1/Tt.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,n=e.y,r=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(n),c=Math.sin(n),h=Math.cos(r),d=Math.sin(r);if("XYZ"===e.order){const e=a*h,i=a*d,n=o*h,r=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=i+n*c,t[5]=e-r*c,t[9]=-o*l,t[2]=r-e*c,t[6]=n+i*c,t[10]=a*l}else if("YXZ"===e.order){const e=l*h,i=l*d,n=c*h,r=c*d;t[0]=e+r*o,t[4]=n*o-i,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=i*o-n,t[6]=r+e*o,t[10]=a*l}else if("ZXY"===e.order){const e=l*h,i=l*d,n=c*h,r=c*d;t[0]=e-r*o,t[4]=-a*d,t[8]=n+i*o,t[1]=i+n*o,t[5]=a*h,t[9]=r-e*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if("ZYX"===e.order){const e=a*h,i=a*d,n=o*h,r=o*d;t[0]=l*h,t[4]=n*c-i,t[8]=e*c+r,t[1]=l*d,t[5]=r*c+e,t[9]=i*c-n,t[2]=-c,t[6]=o*l,t[10]=a*l}else if("YZX"===e.order){const e=a*l,i=a*c,n=o*l,r=o*c;t[0]=l*h,t[4]=r-e*d,t[8]=n*d+i,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=i*d+n,t[10]=e-r*d}else if("XZY"===e.order){const e=a*l,i=a*c,n=o*l,r=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=e*d+r,t[5]=a*h,t[9]=i*d-n,t[2]=n*d-i,t[6]=o*h,t[10]=r*d+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Rt,e,Lt)}lookAt(e,t,i){const n=this.elements;return Pt.subVectors(e,t),0===Pt.lengthSq()&&(Pt.z=1),Pt.normalize(),Dt.crossVectors(i,Pt),0===Dt.lengthSq()&&(1===Math.abs(i.z)?Pt.x+=1e-4:Pt.z+=1e-4,Pt.normalize(),Dt.crossVectors(i,Pt)),Dt.normalize(),Ut.crossVectors(Pt,Dt),n[0]=Dt.x,n[4]=Ut.x,n[8]=Pt.x,n[1]=Dt.y,n[5]=Ut.y,n[9]=Pt.y,n[2]=Dt.z,n[6]=Ut.z,n[10]=Pt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,n=t.elements,r=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],d=i[5],A=i[9],p=i[13],m=i[2],g=i[6],f=i[10],v=i[14],E=i[3],y=i[7],_=i[11],x=i[15],S=n[0],C=n[4],b=n[8],I=n[12],T=n[1],B=n[5],U=n[9],F=n[13],O=n[2],G=n[6],W=n[10],q=n[14],X=n[3],j=n[7],Y=n[11],K=n[15];return r[0]=a*S+o*T+l*O+c*X,r[4]=a*C+o*B+l*G+c*j,r[8]=a*b+o*U+l*W+c*Y,r[12]=a*I+o*F+l*q+c*K,r[1]=h*S+d*T+A*O+p*X,r[5]=h*C+d*B+A*G+p*j,r[9]=h*b+d*U+A*W+p*Y,r[13]=h*I+d*F+A*q+p*K,r[2]=m*S+g*T+f*O+v*X,r[6]=m*C+g*B+f*G+v*j,r[10]=m*b+g*U+f*W+v*Y,r[14]=m*I+g*F+f*q+v*K,r[3]=E*S+y*T+_*O+x*X,r[7]=E*C+y*B+_*G+x*j,r[11]=E*b+y*U+_*W+x*Y,r[15]=E*I+y*F+_*q+x*K,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],n=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],d=e[6],A=e[10],p=e[14];return e[3]*(+r*l*d-n*c*d-r*o*A+i*c*A+n*o*p-i*l*p)+e[7]*(+t*l*p-t*c*A+r*a*A-n*a*p+n*c*h-r*l*h)+e[11]*(+t*c*d-t*o*p-r*a*d+i*a*p+r*o*h-i*c*h)+e[15]*(-n*o*h-t*l*d+t*o*A+n*a*d-i*a*A+i*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],A=e[10],p=e[11],m=e[12],g=e[13],f=e[14],v=e[15],E=d*f*c-g*A*c+g*l*p-o*f*p-d*l*v+o*A*v,y=m*A*c-h*f*c-m*l*p+a*f*p+h*l*v-a*A*v,_=h*g*c-m*d*c+m*o*p-a*g*p-h*o*v+a*d*v,x=m*d*l-h*g*l-m*o*A+a*g*A+h*o*f-a*d*f,S=t*E+i*y+n*_+r*x;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/S;return e[0]=E*C,e[1]=(g*A*r-d*f*r-g*n*p+i*f*p+d*n*v-i*A*v)*C,e[2]=(o*f*r-g*l*r+g*n*c-i*f*c-o*n*v+i*l*v)*C,e[3]=(d*l*r-o*A*r-d*n*c+i*A*c+o*n*p-i*l*p)*C,e[4]=y*C,e[5]=(h*f*r-m*A*r+m*n*p-t*f*p-h*n*v+t*A*v)*C,e[6]=(m*l*r-a*f*r-m*n*c+t*f*c+a*n*v-t*l*v)*C,e[7]=(a*A*r-h*l*r+h*n*c-t*A*c-a*n*p+t*l*p)*C,e[8]=_*C,e[9]=(m*d*r-h*g*r-m*i*p+t*g*p+h*i*v-t*d*v)*C,e[10]=(a*g*r-m*o*r+m*i*c-t*g*c-a*i*v+t*o*v)*C,e[11]=(h*o*r-a*d*r-h*i*c+t*d*c+a*i*p-t*o*p)*C,e[12]=x*C,e[13]=(h*g*n-m*d*n+m*i*A-t*g*A-h*i*f+t*d*f)*C,e[14]=(m*o*n-a*g*n-m*i*l+t*g*l+a*i*f-t*o*f)*C,e[15]=(a*d*n-h*o*n+h*i*l-t*d*l-a*i*A+t*o*A)*C,this}scale(e){const t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),n=Math.sin(t),r=1-i,a=e.x,o=e.y,l=e.z,c=r*a,h=r*o;return this.set(c*a+i,c*o-n*l,c*l+n*o,0,c*o+n*l,h*o+i,h*l-n*a,0,c*l-n*o,h*l+n*a,r*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,a){return this.set(1,i,r,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){const n=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,d=o+o,A=r*c,p=r*h,m=r*d,g=a*h,f=a*d,v=o*d,E=l*c,y=l*h,_=l*d,x=i.x,S=i.y,C=i.z;return n[0]=(1-(g+v))*x,n[1]=(p+_)*x,n[2]=(m-y)*x,n[3]=0,n[4]=(p-_)*S,n[5]=(1-(A+v))*S,n[6]=(f+E)*S,n[7]=0,n[8]=(m+y)*C,n[9]=(f-E)*C,n[10]=(1-(A+g))*C,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){const n=this.elements;let r=Tt.set(n[0],n[1],n[2]).length();const a=Tt.set(n[4],n[5],n[6]).length(),o=Tt.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],Bt.copy(this);const l=1/r,c=1/a,h=1/o;return Bt.elements[0]*=l,Bt.elements[1]*=l,Bt.elements[2]*=l,Bt.elements[4]*=c,Bt.elements[5]*=c,Bt.elements[6]*=c,Bt.elements[8]*=h,Bt.elements[9]*=h,Bt.elements[10]*=h,t.setFromRotationMatrix(Bt),i.x=r,i.y=a,i.z=o,this}makePerspective(e,t,i,n,r,a,o=2e3){const l=this.elements,c=2*r/(t-e),h=2*r/(i-n),d=(t+e)/(t-e),A=(i+n)/(i-n);let p,m;if(o===Ge)p=-(a+r)/(a-r),m=-2*a*r/(a-r);else{if(o!==Ve)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);p=-a/(a-r),m=-a*r/(a-r)}return l[0]=c,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=h,l[9]=A,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,n,r,a,o=2e3){const l=this.elements,c=1/(t-e),h=1/(i-n),d=1/(a-r),A=(t+e)*c,p=(i+n)*h;let m,g;if(o===Ge)m=(a+r)*d,g=-2*d;else{if(o!==Ve)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);m=r*d,g=-1*d}return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-A,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=g,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Tt=new Vector3,Bt=new Matrix4,Rt=new Vector3(0,0,0),Lt=new Vector3(1,1,1),Dt=new Vector3,Ut=new Vector3,Pt=new Vector3,Ft=new Matrix4,Nt=new Quaternion;class Euler{constructor(e=0,t=0,i=0,n=Euler.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const n=e.elements,r=n[0],a=n[4],o=n[8],l=n[1],c=n[5],h=n[9],d=n[2],A=n[6],p=n[10];switch(t){case"XYZ":this._y=Math.asin(clamp$1(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(A,c),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp$1(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(clamp$1(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-clamp$1(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(A,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(clamp$1(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-clamp$1(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(A,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Ft.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ft,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Nt.setFromEuler(this),this.setFromQuaternion(Nt,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Euler.DEFAULT_ORDER="XYZ";class Layers{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return!!(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let Qt=0;const Ot=new Vector3,kt=new Quaternion,Gt=new Matrix4,Vt=new Vector3,Ht=new Vector3,zt=new Vector3,Wt=new Quaternion,qt=new Vector3(1,0,0),Xt=new Vector3(0,1,0),jt=new Vector3(0,0,1),Yt={type:"added"},Kt={type:"removed"};class Object3D extends EventDispatcher{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Qt++}),this.uuid=generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Object3D.DEFAULT_UP.clone();const e=new Vector3,t=new Euler,i=new Quaternion,n=new Vector3(1,1,1);t._onChange((function onRotationChange(){i.setFromEuler(t,!1)})),i._onChange((function onQuaternionChange(){t.setFromQuaternion(i,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Matrix4},normalMatrix:{value:new Matrix3}}),this.matrix=new Matrix4,this.matrixWorld=new Matrix4,this.matrixAutoUpdate=Object3D.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Layers,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return kt.setFromAxisAngle(e,t),this.quaternion.multiply(kt),this}rotateOnWorldAxis(e,t){return kt.setFromAxisAngle(e,t),this.quaternion.premultiply(kt),this}rotateX(e){return this.rotateOnAxis(qt,e)}rotateY(e){return this.rotateOnAxis(Xt,e)}rotateZ(e){return this.rotateOnAxis(jt,e)}translateOnAxis(e,t){return Ot.copy(e).applyQuaternion(this.quaternion),this.position.add(Ot.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(qt,e)}translateY(e){return this.translateOnAxis(Xt,e)}translateZ(e){return this.translateOnAxis(jt,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Gt.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Vt.copy(e):Vt.set(e,t,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Ht.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Gt.lookAt(Ht,Vt,this.up):Gt.lookAt(Vt,Ht,this.up),this.quaternion.setFromRotationMatrix(Gt),n&&(Gt.extractRotation(n.matrixWorld),kt.setFromRotationMatrix(Gt),this.quaternion.premultiply(kt.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(Yt)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Kt)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(Kt)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Gt.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Gt.multiply(e.parent.matrixWorld)),e.applyMatrix4(Gt),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let i=0,n=this.children.length;i<n;i++){const n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}}getObjectsByProperty(e,t){let i=[];this[e]===t&&i.push(this);for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectsByProperty(e,t);r.length>0&&(i=i.concat(r))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ht,e,zt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ht,Wt,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let i=0,n=t.length;i<n;i++){const n=t[i];!0!==n.matrixWorldAutoUpdate&&!0!==e||n.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const i=this.parent;if(!0===e&&null!==i&&!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,i=e.length;t<i;t++){const i=e[t];!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};function serialize(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(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(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=serialize(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const i=t.shapes;if(Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const n=i[t];serialize(e.shapes,n)}else serialize(e.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(serialize(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let i=0,n=this.material.length;i<n;i++)t.push(serialize(e.materials,this.material[i]));n.material=t}else n.material=serialize(e.materials,this.material);if(this.children.length>0){n.children=[];for(let t=0;t<this.children.length;t++)n.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let t=0;t<this.animations.length;t++){const i=this.animations[t];n.animations.push(serialize(e.animations,i))}}if(t){const t=extractFromCache(e.geometries),n=extractFromCache(e.materials),r=extractFromCache(e.textures),a=extractFromCache(e.images),o=extractFromCache(e.shapes),l=extractFromCache(e.skeletons),c=extractFromCache(e.animations),h=extractFromCache(e.nodes);t.length>0&&(i.geometries=t),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 extractFromCache(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const i=e.children[t];this.add(i.clone())}return this}}Object3D.DEFAULT_UP=new Vector3(0,1,0),Object3D.DEFAULT_MATRIX_AUTO_UPDATE=!0,Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const $t=new Vector3,Jt=new Vector3,Zt=new Vector3,ei=new Vector3,ti=new Vector3,ii=new Vector3,ni=new Vector3,ri=new Vector3,si=new Vector3,ai=new Vector3;let oi=!1;class Triangle{constructor(e=new Vector3,t=new Vector3,i=new Vector3){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),$t.subVectors(e,t),n.cross($t);const r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){$t.subVectors(n,t),Jt.subVectors(i,t),Zt.subVectors(e,t);const a=$t.dot($t),o=$t.dot(Jt),l=$t.dot(Zt),c=Jt.dot(Jt),h=Jt.dot(Zt),d=a*c-o*o;if(0===d)return r.set(-2,-1,-1);const A=1/d,p=(c*l-o*h)*A,m=(a*h-o*l)*A;return r.set(1-p-m,m,p)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,ei),ei.x>=0&&ei.y>=0&&ei.x+ei.y<=1}static getUV(e,t,i,n,r,a,o,l){return!1===oi&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),oi=!0),this.getInterpolation(e,t,i,n,r,a,o,l)}static getInterpolation(e,t,i,n,r,a,o,l){return this.getBarycoord(e,t,i,n,ei),l.setScalar(0),l.addScaledVector(r,ei.x),l.addScaledVector(a,ei.y),l.addScaledVector(o,ei.z),l}static isFrontFacing(e,t,i,n){return $t.subVectors(i,t),Jt.subVectors(e,t),$t.cross(Jt).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return $t.subVectors(this.c,this.b),Jt.subVectors(this.a,this.b),.5*$t.cross(Jt).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return!1===oi&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),oi=!0),Triangle.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}getInterpolation(e,t,i,n,r){return Triangle.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,n=this.b,r=this.c;let a,o;ti.subVectors(n,i),ii.subVectors(r,i),ri.subVectors(e,i);const l=ti.dot(ri),c=ii.dot(ri);if(l<=0&&c<=0)return t.copy(i);si.subVectors(e,n);const h=ti.dot(si),d=ii.dot(si);if(h>=0&&d<=h)return t.copy(n);const A=l*d-h*c;if(A<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(ti,a);ai.subVectors(e,r);const p=ti.dot(ai),m=ii.dot(ai);if(m>=0&&p<=m)return t.copy(r);const g=p*c-l*m;if(g<=0&&c>=0&&m<=0)return o=c/(c-m),t.copy(i).addScaledVector(ii,o);const f=h*m-p*d;if(f<=0&&d-h>=0&&p-m>=0)return ni.subVectors(r,n),o=(d-h)/(d-h+(p-m)),t.copy(n).addScaledVector(ni,o);const v=1/(f+g+A);return a=g*v,o=A*v,t.copy(i).addScaledVector(ti,a).addScaledVector(ii,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let li=0;class Material$1 extends EventDispatcher{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:li++}),this.uuid=generateUUID(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=a,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=Te,this.stencilZFail=Te,this.stencilZPass=Te,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const i=e[t];if(void 0===i){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const n=this[t];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function extractFromCache(e){const t=[];for(const i in e){const n=e[i];delete n.metadata,t.push(n)}return t}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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).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(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).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(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).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),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),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=this.alphaHash),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(i.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(i.wireframe=this.wireframe),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=this.flatShading),!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),t){const t=extractFromCache(e.textures),n=extractFromCache(e.images);t.length>0&&(i.textures=t),n.length>0&&(i.images=n)}return i}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(null!==t){const e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const ci={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},hi={h:0,s:0,l:0},ui={h:0,s:0,l:0};function hue2rgb(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}class Color{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(void 0===t&&void 0===i){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=be){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,et.toWorkingColorSpace(this,t),this}setRGB(e,t,i,n=et.workingColorSpace){return this.r=e,this.g=t,this.b=i,et.toWorkingColorSpace(this,n),this}setHSL(e,t,i,n=et.workingColorSpace){if(e=euclideanModulo(e,1),t=clamp$1(t,0,1),i=clamp$1(i,0,1),0===t)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=hue2rgb(r,n,e+1/3),this.g=hue2rgb(r,n,e),this.b=hue2rgb(r,n,e-1/3)}return et.toWorkingColorSpace(this,n),this}setStyle(e,t=be){function handleAlpha(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const r=i[1],a=i[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return handleAlpha(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,t);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return handleAlpha(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return handleAlpha(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=be){const i=ci[e.toLowerCase()];return void 0!==i?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=be){return et.fromWorkingColorSpace(di.copy(this),e),65536*Math.round(clamp$1(255*di.r,0,255))+256*Math.round(clamp$1(255*di.g,0,255))+Math.round(clamp$1(255*di.b,0,255))}getHexString(e=be){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.fromWorkingColorSpace(di.copy(this),t);const i=di.r,n=di.g,r=di.b,a=Math.max(i,n,r),o=Math.min(i,n,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const e=a-o;switch(c=h<=.5?e/(a+o):e/(2-a-o),a){case i:l=(n-r)/e+(n<r?6:0);break;case n:l=(r-i)/e+2;break;case r:l=(i-n)/e+4}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=et.workingColorSpace){return et.fromWorkingColorSpace(di.copy(this),t),e.r=di.r,e.g=di.g,e.b=di.b,e}getStyle(e=be){et.fromWorkingColorSpace(di.copy(this),e);const t=di.r,i=di.g,n=di.b;return e!==be?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(e,t,i){return this.getHSL(hi),hi.h+=e,hi.s+=t,hi.l+=i,this.setHSL(hi.h,hi.s,hi.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(hi),e.getHSL(ui);const i=lerp$1(hi.h,ui.h,t),n=lerp$1(hi.s,ui.s,t),r=lerp$1(hi.l,ui.l,t);return this.setHSL(i,n,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,n=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[8]*n,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const di=new Color;Color.NAMES=ci;class MeshBasicMaterial extends Material$1{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Color(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ai=_generateTables();function _generateTables(){const e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),n=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(n[e]=0,n[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(n[e]=1024>>-t-14,n[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(n[e]=t+15<<10,n[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(n[e]=31744,n[256|e]=64512,r[e]=24,r[256|e]=24):(n[e]=31744,n[256|e]=64512,r[e]=13,r[256|e]=13)}const a=new Uint32Array(2048),o=new Uint32Array(64),l=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,i=0;for(;!(8388608&t);)t<<=1,i-=8388608;t&=-8388609,i+=947912704,a[e]=t|i}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(l[e]=1024);return{floatView:t,uint32View:i,baseTable:n,shiftTable:r,mantissaTable:a,exponentTable:o,offsetTable:l}}const pi={toHalfFloat:function toHalfFloat(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=clamp$1(e,-65504,65504),Ai.floatView[0]=e;const t=Ai.uint32View[0],i=t>>23&511;return Ai.baseTable[i]+((8388607&t)>>Ai.shiftTable[i])},fromHalfFloat:function fromHalfFloat(e){const t=e>>10;return Ai.uint32View[0]=Ai.mantissaTable[Ai.offsetTable[t]+(1023&e)]+Ai.exponentTable[t],Ai.floatView[0]}},mi=new Vector3,gi=new Vector2;class BufferAttribute{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=i,this.usage=Qe,this.updateRange={offset:0,count:-1},this.gpuType=K,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)gi.fromBufferAttribute(this,t),gi.applyMatrix3(e),this.setXY(t,gi.x,gi.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)mi.fromBufferAttribute(this,t),mi.applyMatrix3(e),this.setXYZ(t,mi.x,mi.y,mi.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)mi.fromBufferAttribute(this,t),mi.applyMatrix4(e),this.setXYZ(t,mi.x,mi.y,mi.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)mi.fromBufferAttribute(this,t),mi.applyNormalMatrix(e),this.setXYZ(t,mi.x,mi.y,mi.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)mi.fromBufferAttribute(this,t),mi.transformDirection(e),this.setXYZ(t,mi.x,mi.y,mi.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=denormalize(t,this.array)),t}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=denormalize(t,this.array)),t}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=denormalize(t,this.array)),t}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=denormalize(t,this.array)),t}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),i=normalize(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),i=normalize(i,this.array),n=normalize(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=normalize(t,this.array),i=normalize(i,this.array),n=normalize(n,this.array),r=normalize(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Qe&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}}class Uint16BufferAttribute extends BufferAttribute{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Uint32BufferAttribute extends BufferAttribute{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Float32BufferAttribute extends BufferAttribute{constructor(e,t,i){super(new Float32Array(e),t,i)}}let fi=0;const vi=new Matrix4,yi=new Object3D,_i=new Vector3,xi=new Box3,Ci=new Box3,Mi=new Vector3;class BufferGeometry extends EventDispatcher{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:fi++}),this.uuid=generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(arrayNeedsUint32(e)?Uint32BufferAttribute:Uint16BufferAttribute)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(void 0!==i){const t=(new Matrix3).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return vi.makeRotationFromQuaternion(e),this.applyMatrix4(vi),this}rotateX(e){return vi.makeRotationX(e),this.applyMatrix4(vi),this}rotateY(e){return vi.makeRotationY(e),this.applyMatrix4(vi),this}rotateZ(e){return vi.makeRotationZ(e),this.applyMatrix4(vi),this}translate(e,t,i){return vi.makeTranslation(e,t,i),this.applyMatrix4(vi),this}scale(e,t,i){return vi.makeScale(e,t,i),this.applyMatrix4(vi),this}lookAt(e){return yi.lookAt(e),yi.updateMatrix(),this.applyMatrix4(yi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_i).negate(),this.translate(_i.x,_i.y,_i.z),this}setFromPoints(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e[i];t.push(n.x,n.y,n.z||0)}return this.setAttribute("position",new Float32BufferAttribute(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Box3);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new Vector3(-1/0,-1/0,-1/0),new Vector3(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];xi.setFromBufferAttribute(i),this.morphTargetsRelative?(Mi.addVectors(this.boundingBox.min,xi.min),this.boundingBox.expandByPoint(Mi),Mi.addVectors(this.boundingBox.max,xi.max),this.boundingBox.expandByPoint(Mi)):(this.boundingBox.expandByPoint(xi.min),this.boundingBox.expandByPoint(xi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Sphere);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new Vector3,1/0);if(e){const i=this.boundingSphere.center;if(xi.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){const i=t[e];Ci.setFromBufferAttribute(i),this.morphTargetsRelative?(Mi.addVectors(xi.min,Ci.min),xi.expandByPoint(Mi),Mi.addVectors(xi.max,Ci.max),xi.expandByPoint(Mi)):(xi.expandByPoint(Ci.min),xi.expandByPoint(Ci.max))}xi.getCenter(i);let n=0;for(let t=0,r=e.count;t<r;t++)Mi.fromBufferAttribute(e,t),n=Math.max(n,i.distanceToSquared(Mi));if(t)for(let r=0,a=t.length;r<a;r++){const a=t[r],o=this.morphTargetsRelative;for(let t=0,r=a.count;t<r;t++)Mi.fromBufferAttribute(a,t),o&&(_i.fromBufferAttribute(e,t),Mi.add(_i)),n=Math.max(n,i.distanceToSquared(Mi))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const i=e.array,n=t.position.array,r=t.normal.array,a=t.uv.array,o=n.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new BufferAttribute(new Float32Array(4*o),4));const l=this.getAttribute("tangent").array,c=[],h=[];for(let e=0;e<o;e++)c[e]=new Vector3,h[e]=new Vector3;const d=new Vector3,A=new Vector3,p=new Vector3,m=new Vector2,g=new Vector2,f=new Vector2,v=new Vector3,E=new Vector3;function handleTriangle(e,t,i){d.fromArray(n,3*e),A.fromArray(n,3*t),p.fromArray(n,3*i),m.fromArray(a,2*e),g.fromArray(a,2*t),f.fromArray(a,2*i),A.sub(d),p.sub(d),g.sub(m),f.sub(m);const r=1/(g.x*f.y-f.x*g.y);isFinite(r)&&(v.copy(A).multiplyScalar(f.y).addScaledVector(p,-g.y).multiplyScalar(r),E.copy(p).multiplyScalar(g.x).addScaledVector(A,-f.x).multiplyScalar(r),c[e].add(v),c[t].add(v),c[i].add(v),h[e].add(E),h[t].add(E),h[i].add(E))}let y=this.groups;0===y.length&&(y=[{start:0,count:i.length}]);for(let e=0,t=y.length;e<t;++e){const t=y[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)handleTriangle(i[e+0],i[e+1],i[e+2])}const _=new Vector3,x=new Vector3,S=new Vector3,C=new Vector3;function handleVertex(e){S.fromArray(r,3*e),C.copy(S);const t=c[e];_.copy(t),_.sub(S.multiplyScalar(S.dot(t))).normalize(),x.crossVectors(C,t);const i=x.dot(h[e])<0?-1:1;l[4*e]=_.x,l[4*e+1]=_.y,l[4*e+2]=_.z,l[4*e+3]=i}for(let e=0,t=y.length;e<t;++e){const t=y[e],n=t.start;for(let e=n,r=n+t.count;e<r;e+=3)handleVertex(i[e+0]),handleVertex(i[e+1]),handleVertex(i[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let i=this.getAttribute("normal");if(void 0===i)i=new BufferAttribute(new Float32Array(3*t.count),3),this.setAttribute("normal",i);else for(let e=0,t=i.count;e<t;e++)i.setXYZ(e,0,0,0);const n=new Vector3,r=new Vector3,a=new Vector3,o=new Vector3,l=new Vector3,c=new Vector3,h=new Vector3,d=new Vector3;if(e)for(let A=0,p=e.count;A<p;A+=3){const p=e.getX(A+0),m=e.getX(A+1),g=e.getX(A+2);n.fromBufferAttribute(t,p),r.fromBufferAttribute(t,m),a.fromBufferAttribute(t,g),h.subVectors(a,r),d.subVectors(n,r),h.cross(d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,m),c.fromBufferAttribute(i,g),o.add(h),l.add(h),c.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(m,l.x,l.y,l.z),i.setXYZ(g,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)n.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),h.subVectors(a,r),d.subVectors(n,r),h.cross(d),i.setXYZ(e+0,h.x,h.y,h.z),i.setXYZ(e+1,h.x,h.y,h.z),i.setXYZ(e+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Mi.fromBufferAttribute(e,t),Mi.normalize(),e.setXYZ(t,Mi.x,Mi.y,Mi.z)}toNonIndexed(){function convertBufferAttribute(e,t){const i=e.array,n=e.itemSize,r=e.normalized,a=new i.constructor(t.length*n);let o=0,l=0;for(let r=0,c=t.length;r<c;r++){o=e.isInterleavedBufferAttribute?t[r]*e.data.stride+e.offset:t[r]*n;for(let e=0;e<n;e++)a[l++]=i[o++]}return new BufferAttribute(a,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new BufferGeometry,t=this.index.array,i=this.attributes;for(const n in i){const r=convertBufferAttribute(i[n],t);e.setAttribute(n,r)}const n=this.morphAttributes;for(const i in n){const r=[],a=n[i];for(let e=0,i=a.length;e<i;e++){const i=convertBufferAttribute(a[e],t);r.push(i)}e.morphAttributes[i]=r}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let t=0,i=r.length;t<i;t++){const i=r[t];e.addGroup(i.start,i.count,i.materialIndex)}return e}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const t in i){const n=i[t];e.data.attributes[t]=n.toJSON(e.data)}const n={};let r=!1;for(const t in this.morphAttributes){const i=this.morphAttributes[t],a=[];for(let t=0,n=i.length;t<n;t++){const n=i[t];a.push(n.toJSON(e.data))}a.length>0&&(n[t]=a,r=!0)}r&&(e.data.morphAttributes=n,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;null!==i&&this.setIndex(i.clone(t));const n=e.attributes;for(const e in n){const i=n[e];this.setAttribute(e,i.clone(t))}const r=e.morphAttributes;for(const e in r){const i=[],n=r[e];for(let e=0,r=n.length;e<r;e++)i.push(n[e].clone(t));this.morphAttributes[e]=i}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let e=0,t=a.length;e<t;e++){const t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}const o=e.boundingBox;null!==o&&(this.boundingBox=o.clone());const l=e.boundingSphere;return null!==l&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const bi=new Matrix4,wi=new Ray,Ti=new Sphere,Bi=new Vector3,Ri=new Vector3,Li=new Vector3,Di=new Vector3,Ui=new Vector3,Fi=new Vector3,Ni=new Vector2,Qi=new Vector2,Oi=new Vector2,ki=new Vector3,Gi=new Vector3,Vi=new Vector3,Hi=new Vector3,zi=new Vector3;class Mesh extends Object3D{constructor(e=new BufferGeometry,t=new MeshBasicMaterial){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){const t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);const o=this.morphTargetInfluences;if(r&&o){Fi.set(0,0,0);for(let i=0,n=r.length;i<n;i++){const n=o[i],l=r[i];0!==n&&(Ui.fromBufferAttribute(l,e),a?Fi.addScaledVector(Ui,n):Fi.addScaledVector(Ui.sub(t),n))}t.add(Fi)}return t}raycast(e,t){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0!==n){if(null===i.boundingSphere&&i.computeBoundingSphere(),Ti.copy(i.boundingSphere),Ti.applyMatrix4(r),wi.copy(e.ray).recast(e.near),!1===Ti.containsPoint(wi.origin)){if(null===wi.intersectSphere(Ti,Bi))return;if(wi.origin.distanceToSquared(Bi)>(e.far-e.near)**2)return}bi.copy(r).invert(),wi.copy(e.ray).applyMatrix4(bi),null!==i.boundingBox&&!1===wi.intersectsBox(i.boundingBox)||this._computeIntersections(e,t,wi)}}_computeIntersections(e,t,i){let n;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,A=r.groups,p=r.drawRange;if(null!==o)if(Array.isArray(a))for(let r=0,l=A.length;r<l;r++){const l=A[r],m=a[l.materialIndex];for(let r=Math.max(l.start,p.start),a=Math.min(o.count,Math.min(l.start+l.count,p.start+p.count));r<a;r+=3){n=checkGeometryIntersection(this,m,e,i,c,h,d,o.getX(r),o.getX(r+1),o.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=l.materialIndex,t.push(n))}}else{for(let r=Math.max(0,p.start),l=Math.min(o.count,p.start+p.count);r<l;r+=3){n=checkGeometryIntersection(this,a,e,i,c,h,d,o.getX(r),o.getX(r+1),o.getX(r+2)),n&&(n.faceIndex=Math.floor(r/3),t.push(n))}}else if(void 0!==l)if(Array.isArray(a))for(let r=0,o=A.length;r<o;r++){const o=A[r],m=a[o.materialIndex];for(let r=Math.max(o.start,p.start),a=Math.min(l.count,Math.min(o.start+o.count,p.start+p.count));r<a;r+=3){n=checkGeometryIntersection(this,m,e,i,c,h,d,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),n.face.materialIndex=o.materialIndex,t.push(n))}}else{for(let r=Math.max(0,p.start),o=Math.min(l.count,p.start+p.count);r<o;r+=3){n=checkGeometryIntersection(this,a,e,i,c,h,d,r,r+1,r+2),n&&(n.faceIndex=Math.floor(r/3),t.push(n))}}}}function checkGeometryIntersection(e,t,i,n,r,a,o,l,c,h){e.getVertexPosition(l,Ri),e.getVertexPosition(c,Li),e.getVertexPosition(h,Di);const d=function checkIntersection(e,t,i,n,r,a,o,l){let c;if(c=1===t.side?n.intersectTriangle(o,a,r,!0,l):n.intersectTriangle(r,a,o,0===t.side,l),null===c)return null;zi.copy(l),zi.applyMatrix4(e.matrixWorld);const h=i.ray.origin.distanceTo(zi);return h<i.near||h>i.far?null:{distance:h,point:zi.clone(),object:e}}(e,t,i,n,Ri,Li,Di,Hi);if(d){r&&(Ni.fromBufferAttribute(r,l),Qi.fromBufferAttribute(r,c),Oi.fromBufferAttribute(r,h),d.uv=Triangle.getInterpolation(Hi,Ri,Li,Di,Ni,Qi,Oi,new Vector2)),a&&(Ni.fromBufferAttribute(a,l),Qi.fromBufferAttribute(a,c),Oi.fromBufferAttribute(a,h),d.uv1=Triangle.getInterpolation(Hi,Ri,Li,Di,Ni,Qi,Oi,new Vector2),d.uv2=d.uv1),o&&(ki.fromBufferAttribute(o,l),Gi.fromBufferAttribute(o,c),Vi.fromBufferAttribute(o,h),d.normal=Triangle.getInterpolation(Hi,Ri,Li,Di,ki,Gi,Vi,new Vector3),d.normal.dot(n.direction)>0&&d.normal.multiplyScalar(-1));const e={a:l,b:c,c:h,normal:new Vector3,materialIndex:0};Triangle.getNormal(Ri,Li,Di,e.normal),d.face=e}return d}class BoxGeometry extends BufferGeometry{constructor(e=1,t=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};const o=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],d=[];let A=0,p=0;function buildPlane(e,t,i,n,r,a,m,g,f,v,E){const y=a/f,_=m/v,x=a/2,S=m/2,C=g/2,b=f+1,I=v+1;let T=0,B=0;const U=new Vector3;for(let a=0;a<I;a++){const o=a*_-S;for(let l=0;l<b;l++){const A=l*y-x;U[e]=A*n,U[t]=o*r,U[i]=C,c.push(U.x,U.y,U.z),U[e]=0,U[t]=0,U[i]=g>0?1:-1,h.push(U.x,U.y,U.z),d.push(l/f),d.push(1-a/v),T+=1}}for(let e=0;e<v;e++)for(let t=0;t<f;t++){const i=A+t+b*e,n=A+t+b*(e+1),r=A+(t+1)+b*(e+1),a=A+(t+1)+b*e;l.push(i,n,a),l.push(n,r,a),B+=6}o.addGroup(p,B,E),p+=B,A+=T}buildPlane("z","y","x",-1,-1,i,t,e,a,r,0),buildPlane("z","y","x",1,-1,i,t,-e,a,r,1),buildPlane("x","z","y",1,1,e,i,t,n,a,2),buildPlane("x","z","y",1,-1,e,i,-t,n,a,3),buildPlane("x","y","z",1,-1,e,t,i,n,r,4),buildPlane("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(l),this.setAttribute("position",new Float32BufferAttribute(c,3)),this.setAttribute("normal",new Float32BufferAttribute(h,3)),this.setAttribute("uv",new Float32BufferAttribute(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new BoxGeometry(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function cloneUniforms(e){const t={};for(const i in e){t[i]={};for(const n in e[i]){const r=e[i][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[i][n]=null):t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function mergeUniforms(e){const t={};for(let i=0;i<e.length;i++){const n=cloneUniforms(e[i]);for(const e in n)t[e]=n[e]}return t}function getUnlitUniformColorSpace(e){return null===e.getRenderTarget()?e.outputColorSpace:Ie}const Wi={clone:cloneUniforms,merge:mergeUniforms};class ShaderMaterial extends Material$1{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=cloneUniforms(e.uniforms),this.uniformsGroups=function cloneUniformsGroups(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const n=this.uniforms[i].value;n&&n.isTexture?t.uniforms[i]={type:"t",value:n.toJSON(e).uuid}:n&&n.isColor?t.uniforms[i]={type:"c",value:n.getHex()}:n&&n.isVector2?t.uniforms[i]={type:"v2",value:n.toArray()}:n&&n.isVector3?t.uniforms[i]={type:"v3",value:n.toArray()}:n&&n.isVector4?t.uniforms[i]={type:"v4",value:n.toArray()}:n&&n.isMatrix3?t.uniforms[i]={type:"m3",value:n.toArray()}:n&&n.isMatrix4?t.uniforms[i]={type:"m4",value:n.toArray()}:t.uniforms[i]={value:n}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Camera extends Object3D{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Matrix4,this.projectionMatrix=new Matrix4,this.projectionMatrixInverse=new Matrix4,this.coordinateSystem=Ge}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class PerspectiveCamera extends Camera{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*qe*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*We*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*qe*Math.atan(Math.tan(.5*We*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,r,a){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*We*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,o=a.fullHeight;r+=a.offsetX*n/e,t-=a.offsetY*i/o,n*=a.width/e,i*=a.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const qi=-90;class CubeCamera extends Object3D{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null;const n=new PerspectiveCamera(qi,1,e,t);n.layers=this.layers,this.add(n);const r=new PerspectiveCamera(qi,1,e,t);r.layers=this.layers,this.add(r);const a=new PerspectiveCamera(qi,1,e,t);a.layers=this.layers,this.add(a);const o=new PerspectiveCamera(qi,1,e,t);o.layers=this.layers,this.add(o);const l=new PerspectiveCamera(qi,1,e,t);l.layers=this.layers,this.add(l);const c=new PerspectiveCamera(qi,1,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,n,r,a,o,l]=t;for(const e of t)this.remove(e);if(e===Ge)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),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else{if(e!==Ve)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);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),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[n,r,a,o,l,c]=this.children,h=e.getRenderTarget(),d=e.toneMapping,A=e.xr.enabled;e.toneMapping=0,e.xr.enabled=!1;const p=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,r),e.setRenderTarget(i,2),e.render(t,a),e.setRenderTarget(i,3),e.render(t,o),e.setRenderTarget(i,4),e.render(t,l),i.texture.generateMipmaps=p,e.setRenderTarget(i,5),e.render(t,c),e.setRenderTarget(h),e.toneMapping=d,e.xr.enabled=A,i.texture.needsPMREMUpdate=!0}}class CubeTexture extends Texture$1{constructor(e,t,i,n,r,a,o,l,c,h){super(e=void 0!==e?e:[],t=void 0!==t?t:_,i,n,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class WebGLCubeRenderTarget extends WebGLRenderTarget{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},n=[i,i,i,i,i,i];void 0!==t.encoding&&(warnOnce("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Ce?be:Me),this.texture=new CubeTexture(n,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:O}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const 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 <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\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 <common>\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 BoxGeometry(5,5,5),r=new ShaderMaterial({name:"CubemapFromEquirect",uniforms:cloneUniforms(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;const a=new Mesh(n,r),o=t.minFilter;t.minFilter===W&&(t.minFilter=O);return new CubeCamera(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,i,n){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,i,n);e.setRenderTarget(r)}}const Xi=new Vector3,ji=new Vector3,Yi=new Matrix3;class Plane{constructor(e=new Vector3(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const n=Xi.subVectors(i,t).cross(ji.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const i=e.delta(Xi),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||Yi.getNormalMatrix(e),n=this.coplanarPoint(Xi).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Ki=new Sphere,$i=new Vector3;class Frustum{constructor(e=new Plane,t=new Plane,i=new Plane,n=new Plane,r=new Plane,a=new Plane){this.planes=[e,t,i,n,r,a]}set(e,t,i,n,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=2e3){const i=this.planes,n=e.elements,r=n[0],a=n[1],o=n[2],l=n[3],c=n[4],h=n[5],d=n[6],A=n[7],p=n[8],m=n[9],g=n[10],f=n[11],v=n[12],E=n[13],y=n[14],_=n[15];if(i[0].setComponents(l-r,A-c,f-p,_-v).normalize(),i[1].setComponents(l+r,A+c,f+p,_+v).normalize(),i[2].setComponents(l+a,A+h,f+m,_+E).normalize(),i[3].setComponents(l-a,A-h,f-m,_-E).normalize(),i[4].setComponents(l-o,A-d,f-g,_-y).normalize(),t===Ge)i[5].setComponents(l+o,A+d,f+g,_+y).normalize();else{if(t!==Ve)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);i[5].setComponents(o,d,g,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){return Ki.center.set(0,0,0),Ki.radius=.7071067811865476,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,n=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(i)<n)return!1}return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const n=t[i];if($i.x=n.normal.x>0?e.max.x:e.min.x,$i.y=n.normal.y>0?e.max.y:e.min.y,$i.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint($i)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function WebGLAnimation(){let e=null,t=!1,i=null,n=null;function onAnimationFrame(t,r){i(t,r),n=e.requestAnimationFrame(onAnimationFrame)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(onAnimationFrame),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function WebGLAttributes(e,t){const i=t.isWebGL2,n=new WeakMap;return{get:function get(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function remove(t){t.isInterleavedBufferAttribute&&(t=t.data);const i=n.get(t);i&&(e.deleteBuffer(i.buffer),n.delete(t))},update:function update(t,r){if(t.isGLBufferAttribute){const e=n.get(t);return void((!e||e.version<t.version)&&n.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const a=n.get(t);void 0===a?n.set(t,function createBuffer(t,n){const r=t.array,a=t.usage,o=e.createBuffer();let l;if(e.bindBuffer(n,o),e.bufferData(n,r,a),t.onUploadCallback(),r instanceof Float32Array)l=e.FLOAT;else if(r instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!i)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");l=e.HALF_FLOAT}else l=e.UNSIGNED_SHORT;else if(r instanceof Int16Array)l=e.SHORT;else if(r instanceof Uint32Array)l=e.UNSIGNED_INT;else if(r instanceof Int32Array)l=e.INT;else if(r instanceof Int8Array)l=e.BYTE;else if(r instanceof Uint8Array)l=e.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);l=e.UNSIGNED_BYTE}return{buffer:o,type:l,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(t,r)):a.version<t.version&&(!function updateBuffer(t,n,r){const a=n.array,o=n.updateRange;e.bindBuffer(r,t),-1===o.count?e.bufferSubData(r,0,a):(i?e.bufferSubData(r,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):e.bufferSubData(r,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1),n.onUploadCallback()}(a.buffer,t,r),a.version=t.version)}}}class PlaneGeometry extends BufferGeometry{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};const r=e/2,a=t/2,o=Math.floor(i),l=Math.floor(n),c=o+1,h=l+1,d=e/o,A=t/l,p=[],m=[],g=[],f=[];for(let e=0;e<h;e++){const t=e*A-a;for(let i=0;i<c;i++){const n=i*d-r;m.push(n,-t,0),g.push(0,0,1),f.push(i/o),f.push(1-e/l)}}for(let e=0;e<l;e++)for(let t=0;t<o;t++){const i=t+c*e,n=t+c*(e+1),r=t+1+c*(e+1),a=t+1+c*e;p.push(i,n,a),p.push(n,r,a)}this.setIndex(p),this.setAttribute("position",new Float32BufferAttribute(m,3)),this.setAttribute("normal",new Float32BufferAttribute(g,3)),this.setAttribute("uv",new Float32BufferAttribute(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new PlaneGeometry(e.width,e.height,e.widthSegments,e.heightSegments)}}const Ji={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660,  0.0556434,\n\t\t-1.5371385,  1.8760108, -0.2040259,\n\t\t-0.4985314,  0.0415560,  1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\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:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( 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}",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 GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, 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 GeometricContext geometry, 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;\nuniform vec3 lightProbe[ 9 ];\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, const in GeometricContext geometry, 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 GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\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 GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\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 GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, 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( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, 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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, 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( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, 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:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\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, geometry, 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, geometry, 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, geometry, 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, geometry, 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, geometry, 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, geometry, 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, geometry, 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\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\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 ], geometry.normal );\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( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, 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\tdiffuseColor *= texture2D( map, vMapUv );\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 geometryNormal = 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 = geometryNormal;\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\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <cube_uv_reflection_fragment>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\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 <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\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 <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\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 <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\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( geometry.clearcoatNormal, geometry.viewDir ) );\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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\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 <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"},Zi={common:{diffuse:{value:new Color(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Matrix3}},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 Matrix3}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Matrix3}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Matrix3},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Matrix3},normalScale:{value:new Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Matrix3},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Matrix3}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Matrix3}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Matrix3}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Color(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 Color(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0},uvTransform:{value:new Matrix3}},sprite:{diffuse:{value:new Color(16777215)},opacity:{value:1},center:{value:new Vector2(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new Matrix3},alphaTest:{value:0}}},en={basic:{uniforms:mergeUniforms([Zi.common,Zi.specularmap,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.fog]),vertexShader:Ji.meshbasic_vert,fragmentShader:Ji.meshbasic_frag},lambert:{uniforms:mergeUniforms([Zi.common,Zi.specularmap,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.fog,Zi.lights,{emissive:{value:new Color(0)}}]),vertexShader:Ji.meshlambert_vert,fragmentShader:Ji.meshlambert_frag},phong:{uniforms:mergeUniforms([Zi.common,Zi.specularmap,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.fog,Zi.lights,{emissive:{value:new Color(0)},specular:{value:new Color(1118481)},shininess:{value:30}}]),vertexShader:Ji.meshphong_vert,fragmentShader:Ji.meshphong_frag},standard:{uniforms:mergeUniforms([Zi.common,Zi.envmap,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.roughnessmap,Zi.metalnessmap,Zi.fog,Zi.lights,{emissive:{value:new Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ji.meshphysical_vert,fragmentShader:Ji.meshphysical_frag},toon:{uniforms:mergeUniforms([Zi.common,Zi.aomap,Zi.lightmap,Zi.emissivemap,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.gradientmap,Zi.fog,Zi.lights,{emissive:{value:new Color(0)}}]),vertexShader:Ji.meshtoon_vert,fragmentShader:Ji.meshtoon_frag},matcap:{uniforms:mergeUniforms([Zi.common,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,Zi.fog,{matcap:{value:null}}]),vertexShader:Ji.meshmatcap_vert,fragmentShader:Ji.meshmatcap_frag},points:{uniforms:mergeUniforms([Zi.points,Zi.fog]),vertexShader:Ji.points_vert,fragmentShader:Ji.points_frag},dashed:{uniforms:mergeUniforms([Zi.common,Zi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ji.linedashed_vert,fragmentShader:Ji.linedashed_frag},depth:{uniforms:mergeUniforms([Zi.common,Zi.displacementmap]),vertexShader:Ji.depth_vert,fragmentShader:Ji.depth_frag},normal:{uniforms:mergeUniforms([Zi.common,Zi.bumpmap,Zi.normalmap,Zi.displacementmap,{opacity:{value:1}}]),vertexShader:Ji.meshnormal_vert,fragmentShader:Ji.meshnormal_frag},sprite:{uniforms:mergeUniforms([Zi.sprite,Zi.fog]),vertexShader:Ji.sprite_vert,fragmentShader:Ji.sprite_frag},background:{uniforms:{uvTransform:{value:new Matrix3},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ji.background_vert,fragmentShader:Ji.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ji.backgroundCube_vert,fragmentShader:Ji.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ji.cube_vert,fragmentShader:Ji.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ji.equirect_vert,fragmentShader:Ji.equirect_frag},distanceRGBA:{uniforms:mergeUniforms([Zi.common,Zi.displacementmap,{referencePosition:{value:new Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ji.distanceRGBA_vert,fragmentShader:Ji.distanceRGBA_frag},shadow:{uniforms:mergeUniforms([Zi.lights,Zi.fog,{color:{value:new Color(0)},opacity:{value:1}}]),vertexShader:Ji.shadow_vert,fragmentShader:Ji.shadow_frag}};en.physical={uniforms:mergeUniforms([en.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Matrix3},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Matrix3},clearcoatNormalScale:{value:new Vector2(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Matrix3},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Matrix3},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Matrix3},sheen:{value:0},sheenColor:{value:new Color(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Matrix3},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Matrix3},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Matrix3},transmissionSamplerSize:{value:new Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Matrix3},attenuationDistance:{value:0},attenuationColor:{value:new Color(0)},specularColor:{value:new Color(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Matrix3},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Matrix3},anisotropyVector:{value:new Vector2},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Matrix3}}]),vertexShader:Ji.meshphysical_vert,fragmentShader:Ji.meshphysical_frag};const tn={r:0,b:0,g:0};function WebGLBackground(e,t,i,n,r,a,o){const l=new Color(0);let c,h,d=!0===a?0:1,A=null,p=0,m=null;function setClear(t,i){t.getRGB(tn,getUnlitUniformColorSpace(e)),n.buffers.color.setClear(tn.r,tn.g,tn.b,i,o)}return{getClearColor:function(){return l},setClearColor:function(e,t=1){l.set(e),d=t,setClear(l,d)},getClearAlpha:function(){return d},setClearAlpha:function(e){d=e,setClear(l,d)},render:function render(a,g){let f=!1,v=!0===g.isScene?g.background:null;if(v&&v.isTexture){v=(g.backgroundBlurriness>0?i:t).get(v)}switch(null===v?setClear(l,d):v&&v.isColor&&(setClear(v,1),f=!0),e.xr.getEnvironmentBlendMode()){case"opaque":f=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,o),f=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,o),f=!0}(e.autoClear||f)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===C)?(void 0===h&&(h=new Mesh(new BoxGeometry(1,1,1),new ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(en.backgroundCube.uniforms),vertexShader:en.backgroundCube.vertexShader,fragmentShader:en.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),h.material.uniforms.envMap.value=v,h.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,h.material.toneMapped=v.colorSpace!==be,A===v&&p===v.version&&m===e.toneMapping||(h.material.needsUpdate=!0,A=v,p=v.version,m=e.toneMapping),h.layers.enableAll(),a.unshift(h,h.geometry,h.material,0,0,null)):v&&v.isTexture&&(void 0===c&&(c=new Mesh(new PlaneGeometry(2,2),new ShaderMaterial({name:"BackgroundMaterial",uniforms:cloneUniforms(en.background.uniforms),vertexShader:en.background.vertexShader,fragmentShader:en.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=v,c.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,c.material.toneMapped=v.colorSpace!==be,!0===v.matrixAutoUpdate&&v.updateMatrix(),c.material.uniforms.uvTransform.value.copy(v.matrix),A===v&&p===v.version&&m===e.toneMapping||(c.material.needsUpdate=!0,A=v,p=v.version,m=e.toneMapping),c.layers.enableAll(),a.unshift(c,c.geometry,c.material,0,0,null))}}}function WebGLBindingStates(e,t,i,n){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=n.isWebGL2?null:t.get("OES_vertex_array_object"),o=n.isWebGL2||null!==a,l={},c=createBindingState(null);let h=c,d=!1;function bindVertexArrayObject(t){return n.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function deleteVertexArrayObject(t){return n.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function createBindingState(e){const t=[],i=[],n=[];for(let e=0;e<r;e++)t[e]=0,i[e]=0,n[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:n,object:e,attributes:{},index:null}}function initAttributes(){const e=h.newAttributes;for(let t=0,i=e.length;t<i;t++)e[t]=0}function enableAttribute(e){enableAttributeAndDivisor(e,0)}function enableAttributeAndDivisor(i,r){const a=h.newAttributes,o=h.enabledAttributes,l=h.attributeDivisors;if(a[i]=1,0===o[i]&&(e.enableVertexAttribArray(i),o[i]=1),l[i]!==r){(n.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),l[i]=r}}function disableUnusedAttributes(){const t=h.newAttributes,i=h.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==t[n]&&(e.disableVertexAttribArray(n),i[n]=0)}function vertexAttribPointer(t,i,n,r,a,o,l){!0===l?e.vertexAttribIPointer(t,i,n,a,o):e.vertexAttribPointer(t,i,n,r,a,o)}function reset(){resetDefaultState(),d=!0,h!==c&&(h=c,bindVertexArrayObject(h.object))}function resetDefaultState(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:function setup(r,c,A,p,m){let g=!1;if(o){const t=function getBindingState(t,i,r){const o=!0===r.wireframe;let c=l[t.id];void 0===c&&(c={},l[t.id]=c);let h=c[i.id];void 0===h&&(h={},c[i.id]=h);let d=h[o];void 0===d&&(d=createBindingState(function createVertexArrayObject(){return n.isWebGL2?e.createVertexArray():a.createVertexArrayOES()}()),h[o]=d);return d}(p,A,c);h!==t&&(h=t,bindVertexArrayObject(h.object)),g=function needsUpdate(e,t,i,n){const r=h.attributes,a=t.attributes;let o=0;const l=i.getAttributes();for(const t in l){if(l[t].location>=0){const i=r[t];let n=a[t];if(void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor)),void 0===i)return!0;if(i.attribute!==n)return!0;if(n&&i.data!==n.data)return!0;o++}}return h.attributesNum!==o||h.index!==n}(r,p,A,m),g&&function saveCache(e,t,i,n){const r={},a=t.attributes;let o=0;const l=i.getAttributes();for(const t in l){if(l[t].location>=0){let i=a[t];void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor));const n={};n.attribute=i,i&&i.data&&(n.data=i.data),r[t]=n,o++}}h.attributes=r,h.attributesNum=o,h.index=n}(r,p,A,m)}else{const e=!0===c.wireframe;h.geometry===p.id&&h.program===A.id&&h.wireframe===e||(h.geometry=p.id,h.program=A.id,h.wireframe=e,g=!0)}null!==m&&i.update(m,e.ELEMENT_ARRAY_BUFFER),(g||d)&&(d=!1,function setupVertexAttributes(r,a,o,l){if(!1===n.isWebGL2&&(r.isInstancedMesh||l.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;initAttributes();const c=l.attributes,h=o.getAttributes(),d=a.defaultAttributeValues;for(const t in h){const a=h[t];if(a.location>=0){let o=c[t];if(void 0===o&&("instanceMatrix"===t&&r.instanceMatrix&&(o=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(o=r.instanceColor)),void 0!==o){const t=o.normalized,c=o.itemSize,h=i.get(o);if(void 0===h)continue;const d=h.buffer,A=h.type,p=h.bytesPerElement,m=!0===n.isWebGL2&&(A===e.INT||A===e.UNSIGNED_INT||o.gpuType===j);if(o.isInterleavedBufferAttribute){const i=o.data,n=i.stride,h=o.offset;if(i.isInstancedInterleavedBuffer){for(let e=0;e<a.locationSize;e++)enableAttributeAndDivisor(a.location+e,i.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===l._maxInstanceCount&&(l._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let e=0;e<a.locationSize;e++)enableAttribute(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,d);for(let e=0;e<a.locationSize;e++)vertexAttribPointer(a.location+e,c/a.locationSize,A,t,n*p,(h+c/a.locationSize*e)*p,m)}else{if(o.isInstancedBufferAttribute){for(let e=0;e<a.locationSize;e++)enableAttributeAndDivisor(a.location+e,o.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===l._maxInstanceCount&&(l._maxInstanceCount=o.meshPerAttribute*o.count)}else for(let e=0;e<a.locationSize;e++)enableAttribute(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,d);for(let e=0;e<a.locationSize;e++)vertexAttribPointer(a.location+e,c/a.locationSize,A,t,c*p,c/a.locationSize*e*p,m)}}else if(void 0!==d){const i=d[t];if(void 0!==i)switch(i.length){case 2:e.vertexAttrib2fv(a.location,i);break;case 3:e.vertexAttrib3fv(a.location,i);break;case 4:e.vertexAttrib4fv(a.location,i);break;default:e.vertexAttrib1fv(a.location,i)}}}}disableUnusedAttributes()}(r,c,A,p),null!==m&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i.get(m).buffer))},reset,resetDefaultState,dispose:function dispose(){reset();for(const e in l){const t=l[e];for(const e in t){const i=t[e];for(const e in i)deleteVertexArrayObject(i[e].object),delete i[e];delete t[e]}delete l[e]}},releaseStatesOfGeometry:function releaseStatesOfGeometry(e){if(void 0===l[e.id])return;const t=l[e.id];for(const e in t){const i=t[e];for(const e in i)deleteVertexArrayObject(i[e].object),delete i[e];delete t[e]}delete l[e.id]},releaseStatesOfProgram:function releaseStatesOfProgram(e){for(const t in l){const i=l[t];if(void 0===i[e.id])continue;const n=i[e.id];for(const e in n)deleteVertexArrayObject(n[e].object),delete n[e];delete i[e.id]}},initAttributes,enableAttribute,disableUnusedAttributes}}function WebGLBufferRenderer(e,t,i,n){const r=n.isWebGL2;let a;this.setMode=function setMode(e){a=e},this.render=function render(t,n){e.drawArrays(a,t,n),i.update(n,a,1)},this.renderInstances=function renderInstances(n,o,l){if(0===l)return;let c,h;if(r)c=e,h="drawArraysInstanced";else if(c=t.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===c)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[h](a,n,o,l),i.update(o,a,l)}}function WebGLCapabilities(e,t,i){let n;function getMaxPrecision(t){if("highp"===t){if(e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const r="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let a=void 0!==i.precision?i.precision:"highp";const o=getMaxPrecision(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=r||t.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),A=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),g=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),f=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),E=d>0,y=r||t.has("OES_texture_float");return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy:function getMaxAnisotropy(){if(void 0!==n)return n;if(!0===t.has("EXT_texture_filter_anisotropic")){const i=t.get("EXT_texture_filter_anisotropic");n=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:A,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:g,maxVaryings:f,maxFragmentUniforms:v,vertexTextures:E,floatFragmentTextures:y,floatVertexTextures:E&&y,maxSamples:r?e.getParameter(e.MAX_SAMPLES):0}}function WebGLClipping(e){const t=this;let i=null,n=0,r=!1,a=!1;const o=new Plane,l=new Matrix3,c={value:null,needsUpdate:!1};function projectPlanes(e,i,n,r){const a=null!==e?e.length:0;let h=null;if(0!==a){if(h=c.value,!0!==r||null===h){const t=n+4*a,r=i.matrixWorldInverse;l.getNormalMatrix(r),(null===h||h.length<t)&&(h=new Float32Array(t));for(let t=0,i=n;t!==a;++t,i+=4)o.copy(e[t]).applyMatrix4(r,l),o.normal.toArray(h,i),h[i+3]=o.constant}c.value=h,c.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,h}this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const i=0!==e.length||t||0!==n||r;return r=t,n=e.length,i},this.beginShadows=function(){a=!0,projectPlanes(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){i=projectPlanes(e,t,0)},this.setState=function(o,l,h){const d=o.clippingPlanes,A=o.clipIntersection,p=o.clipShadows,m=e.get(o);if(!r||null===d||0===d.length||a&&!p)a?projectPlanes(null):function resetGlobalState(){c.value!==i&&(c.value=i,c.needsUpdate=n>0);t.numPlanes=n,t.numIntersection=0}();else{const e=a?0:n,t=4*e;let r=m.clippingState||null;c.value=r,r=projectPlanes(d,l,t,h);for(let e=0;e!==t;++e)r[e]=i[e];m.clippingState=r,this.numIntersection=A?this.numPlanes:0,this.numPlanes+=e}}}function WebGLCubeMaps(e){let t=new WeakMap;function mapTextureMapping(e,t){return t===S?e.mapping=_:304===t&&(e.mapping=x),e}function onTextureDispose(e){const i=e.target;i.removeEventListener("dispose",onTextureDispose);const n=t.get(i);void 0!==n&&(t.delete(i),n.dispose())}return{get:function get(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const n=i.mapping;if(n===S||304===n){if(t.has(i)){return mapTextureMapping(t.get(i).texture,i.mapping)}{const n=i.image;if(n&&n.height>0){const r=new WebGLCubeRenderTarget(n.height/2);return r.fromEquirectangularTexture(e,i),t.set(i,r),i.addEventListener("dispose",onTextureDispose),mapTextureMapping(r.texture,i.mapping)}return null}}}return i},dispose:function dispose(){t=new WeakMap}}}class OrthographicCamera extends Camera{constructor(e=-1,t=1,i=1,n=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=n,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,n,r,a){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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=n+t,l=n-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,o-=t*this.view.offsetY,l=o-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const nn=[.125,.215,.35,.446,.526,.582],rn=20,sn=new OrthographicCamera,an=new Color;let on=null;const cn=(1+Math.sqrt(5))/2,hn=1/cn,un=[new Vector3(1,1,1),new Vector3(-1,1,1),new Vector3(1,1,-1),new Vector3(-1,1,-1),new Vector3(0,cn,hn),new Vector3(0,cn,-hn),new Vector3(hn,0,cn),new Vector3(-hn,0,cn),new Vector3(cn,hn,0),new Vector3(-cn,hn,0)];class PMREMGenerator{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,n=100){on=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,i,n,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(on),e.scissorTest=!1,_setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===_||e.mapping===x?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),on=this._renderer.getRenderTarget();const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:O,minFilter:O,generateMipmaps:!1,type:$,format:ee,colorSpace:Ie,depthBuffer:!1},n=_createRenderTarget(e,t,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=_createRenderTarget(e,t,i);const{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function _createPlanes(e){const t=[],i=[],n=[];let r=e;const a=e-4+1+nn.length;for(let o=0;o<a;o++){const a=Math.pow(2,r);i.push(a);let l=1/a;o>e-4?l=nn[o-e+4-1]:0===o&&(l=0),n.push(l);const c=1/(a-2),h=-c,d=1+c,A=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,m=6,g=3,f=2,v=1,E=new Float32Array(g*m*p),y=new Float32Array(f*m*p),_=new Float32Array(v*m*p);for(let e=0;e<p;e++){const t=e%3*2/3-1,i=e>2?0:-1,n=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0];E.set(n,g*m*e),y.set(A,f*m*e);const r=[e,e,e,e,e,e];_.set(r,v*m*e)}const x=new BufferGeometry;x.setAttribute("position",new BufferAttribute(E,g)),x.setAttribute("uv",new BufferAttribute(y,f)),x.setAttribute("faceIndex",new BufferAttribute(_,v)),t.push(x),r>4&&r--}return{lodPlanes:t,sizeLods:i,sigmas:n}}(n)),this._blurMaterial=function _getBlurShader(e,t,i){const n=new Float32Array(rn),r=new Vector3(0,1,0),a=new ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:rn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:_getCommonVertexShader(),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 <cube_uv_reflection_fragment>\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 a}(n,e,t)}return n}_compileMaterial(e){const t=new Mesh(this._lodPlanes[0],e);this._renderer.compile(t,sn)}_sceneToCubeUV(e,t,i,n){const r=new PerspectiveCamera(90,1,t,i),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,c=l.autoClear,h=l.toneMapping;l.getClearColor(an),l.toneMapping=0,l.autoClear=!1;const d=new MeshBasicMaterial({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),A=new Mesh(new BoxGeometry,d);let p=!1;const m=e.background;m?m.isColor&&(d.color.copy(m),e.background=null,p=!0):(d.color.copy(an),p=!0);for(let t=0;t<6;t++){const i=t%3;0===i?(r.up.set(0,a[t],0),r.lookAt(o[t],0,0)):1===i?(r.up.set(0,0,a[t]),r.lookAt(0,o[t],0)):(r.up.set(0,a[t],0),r.lookAt(0,0,o[t]));const c=this._cubeSize;_setViewport(n,i*c,t>2?c:0,c,c),l.setRenderTarget(n),p&&l.render(A,r),l.render(e,r)}A.geometry.dispose(),A.material.dispose(),l.toneMapping=h,l.autoClear=c,e.background=m}_textureToCubeUV(e,t){const i=this._renderer,n=e.mapping===_||e.mapping===x;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial());const r=n?this._cubemapMaterial:this._equirectMaterial,a=new Mesh(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const o=this._cubeSize;_setViewport(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(a,sn)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const i=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),n=un[(t-1)%un.length];this._blur(e,t-1,t,i,n)}t.autoClear=i}_blur(e,t,i,n,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",r),this._halfBlur(a,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,r,a,o){const l=this._renderer,c=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");const h=new Mesh(this._lodPlanes[n],c),d=c.uniforms,A=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*A):2*Math.PI/39,m=r/p,g=isFinite(r)?1+Math.floor(3*m):rn;g>rn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);const f=[];let v=0;for(let e=0;e<rn;++e){const t=e/m,i=Math.exp(-t*t/2);f.push(i),0===e?v+=i:e<g&&(v+=2*i)}for(let e=0;e<f.length;e++)f[e]=f[e]/v;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=f,d.latitudinal.value="latitudinal"===a,o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=p,d.mipInt.value=E-i;const y=this._sizeLods[n];_setViewport(t,3*y*(n>E-4?n-E+4:0),4*(this._cubeSize-y),3*y,2*y),l.setRenderTarget(t),l.render(h,sn)}}function _createRenderTarget(e,t,i){const n=new WebGLRenderTarget(e,t,i);return n.texture.mapping=C,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function _setViewport(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function _getEquirectMaterial(){return new ShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_getCommonVertexShader(),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 <common>\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 _getCubemapMaterial(){return new ShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_getCommonVertexShader(),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 _getCommonVertexShader(){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 WebGLCubeUVMaps(e){let t=new WeakMap,i=null;function onTextureDispose(e){const i=e.target;i.removeEventListener("dispose",onTextureDispose);const n=t.get(i);void 0!==n&&(t.delete(i),n.dispose())}return{get:function get(n){if(n&&n.isTexture){const r=n.mapping,a=r===S||304===r,o=r===_||r===x;if(a||o){if(n.isRenderTargetTexture&&!0===n.needsPMREMUpdate){n.needsPMREMUpdate=!1;let r=t.get(n);return null===i&&(i=new PMREMGenerator(e)),r=a?i.fromEquirectangular(n,r):i.fromCubemap(n,r),t.set(n,r),r.texture}if(t.has(n))return t.get(n).texture;{const r=n.image;if(a&&r&&r.height>0||o&&r&&function isCubeTextureComplete(e){let t=0;const i=6;for(let n=0;n<i;n++)void 0!==e[n]&&t++;return t===i}(r)){null===i&&(i=new PMREMGenerator(e));const r=a?i.fromEquirectangular(n):i.fromCubemap(n);return t.set(n,r),n.addEventListener("dispose",onTextureDispose),r.texture}return null}}}return n},dispose:function dispose(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function WebGLExtensions(e){const t={};function getExtension(i){if(void 0!==t[i])return t[i];let n;switch(i){case"WEBGL_depth_texture":n=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=e.getExtension(i)}return t[i]=n,n}return{has:function(e){return null!==getExtension(e)},init:function(e){e.isWebGL2?getExtension("EXT_color_buffer_float"):(getExtension("WEBGL_depth_texture"),getExtension("OES_texture_float"),getExtension("OES_texture_half_float"),getExtension("OES_texture_half_float_linear"),getExtension("OES_standard_derivatives"),getExtension("OES_element_index_uint"),getExtension("OES_vertex_array_object"),getExtension("ANGLE_instanced_arrays")),getExtension("OES_texture_float_linear"),getExtension("EXT_color_buffer_half_float"),getExtension("WEBGL_multisampled_render_to_texture")},get:function(e){const t=getExtension(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function WebGLGeometries(e,t,i,n){const r={},a=new WeakMap;function onGeometryDispose(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);for(const e in o.morphAttributes){const i=o.morphAttributes[e];for(let e=0,n=i.length;e<n;e++)t.remove(i[e])}o.removeEventListener("dispose",onGeometryDispose),delete r[o.id];const l=a.get(o);l&&(t.remove(l),a.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function updateWireframeAttribute(e){const i=[],n=e.index,r=e.attributes.position;let o=0;if(null!==n){const e=n.array;o=n.version;for(let t=0,n=e.length;t<n;t+=3){const n=e[t+0],r=e[t+1],a=e[t+2];i.push(n,r,r,a,a,n)}}else{const e=r.array;o=r.version;for(let t=0,n=e.length/3-1;t<n;t+=3){const e=t+0,n=t+1,r=t+2;i.push(e,n,n,r,r,e)}}const l=new(arrayNeedsUint32(i)?Uint32BufferAttribute:Uint16BufferAttribute)(i,1);l.version=o;const c=a.get(e);c&&t.remove(c),a.set(e,l)}return{get:function get(e,t){return!0===r[t.id]||(t.addEventListener("dispose",onGeometryDispose),r[t.id]=!0,i.memory.geometries++),t},update:function update(i){const n=i.attributes;for(const i in n)t.update(n[i],e.ARRAY_BUFFER);const r=i.morphAttributes;for(const i in r){const n=r[i];for(let i=0,r=n.length;i<r;i++)t.update(n[i],e.ARRAY_BUFFER)}},getWireframeAttribute:function getWireframeAttribute(e){const t=a.get(e);if(t){const i=e.index;null!==i&&t.version<i.version&&updateWireframeAttribute(e)}else updateWireframeAttribute(e);return a.get(e)}}}function WebGLIndexedBufferRenderer(e,t,i,n){const r=n.isWebGL2;let a,o,l;this.setMode=function setMode(e){a=e},this.setIndex=function setIndex(e){o=e.type,l=e.bytesPerElement},this.render=function render(t,n){e.drawElements(a,n,o,t*l),i.update(n,a,1)},this.renderInstances=function renderInstances(n,c,h){if(0===h)return;let d,A;if(r)d=e,A="drawElementsInstanced";else if(d=t.get("ANGLE_instanced_arrays"),A="drawElementsInstancedANGLE",null===d)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");d[A](a,c,o,n*l,h),i.update(c,a,h)}}function WebGLInfo(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function reset(){t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function update(i,n,r){switch(t.calls++,n){case e.TRIANGLES:t.triangles+=r*(i/3);break;case e.LINES:t.lines+=r*(i/2);break;case e.LINE_STRIP:t.lines+=r*(i-1);break;case e.LINE_LOOP:t.lines+=r*i;break;case e.POINTS:t.points+=r*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function numericalSort(e,t){return e[0]-t[0]}function absNumericalSort(e,t){return Math.abs(t[1])-Math.abs(e[1])}function WebGLMorphtargets(e,t,i){const n={},r=new Float32Array(8),a=new WeakMap,o=new Vector4,l=[];for(let e=0;e<8;e++)l[e]=[e,0];return{update:function update(c,h,d){const A=c.morphTargetInfluences;if(!0===t.isWebGL2){const p=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,m=void 0!==p?p.length:0;let g=a.get(h);if(void 0===g||g.count!==m){void 0!==g&&g.texture.dispose();const E=void 0!==h.morphAttributes.position,y=void 0!==h.morphAttributes.normal,_=void 0!==h.morphAttributes.color,x=h.morphAttributes.position||[],S=h.morphAttributes.normal||[],C=h.morphAttributes.color||[];let b=0;!0===E&&(b=1),!0===y&&(b=2),!0===_&&(b=3);let I=h.attributes.position.count*b,T=1;I>t.maxTextureSize&&(T=Math.ceil(I/t.maxTextureSize),I=t.maxTextureSize);const B=new Float32Array(I*T*4*m),U=new DataArrayTexture(B,I,T,m);U.type=K,U.needsUpdate=!0;const F=4*b;for(let O=0;O<m;O++){const G=x[O],W=S[O],q=C[O],X=I*T*4*O;for(let j=0;j<G.count;j++){const Y=j*F;!0===E&&(o.fromBufferAttribute(G,j),B[X+Y+0]=o.x,B[X+Y+1]=o.y,B[X+Y+2]=o.z,B[X+Y+3]=0),!0===y&&(o.fromBufferAttribute(W,j),B[X+Y+4]=o.x,B[X+Y+5]=o.y,B[X+Y+6]=o.z,B[X+Y+7]=0),!0===_&&(o.fromBufferAttribute(q,j),B[X+Y+8]=o.x,B[X+Y+9]=o.y,B[X+Y+10]=o.z,B[X+Y+11]=4===q.itemSize?o.w:1)}}function disposeTexture(){U.dispose(),a.delete(h),h.removeEventListener("dispose",disposeTexture)}g={count:m,texture:U,size:new Vector2(I,T)},a.set(h,g),h.addEventListener("dispose",disposeTexture)}let f=0;for(let $=0;$<A.length;$++)f+=A[$];const v=h.morphTargetsRelative?1:1-f;d.getUniforms().setValue(e,"morphTargetBaseInfluence",v),d.getUniforms().setValue(e,"morphTargetInfluences",A),d.getUniforms().setValue(e,"morphTargetsTexture",g.texture,i),d.getUniforms().setValue(e,"morphTargetsTextureSize",g.size)}else{const J=void 0===A?0:A.length;let ee=n[h.id];if(void 0===ee||ee.length!==J){ee=[];for(let se=0;se<J;se++)ee[se]=[se,0];n[h.id]=ee}for(let ae=0;ae<J;ae++){const oe=ee[ae];oe[0]=ae,oe[1]=A[ae]}ee.sort(absNumericalSort);for(let le=0;le<8;le++)le<J&&ee[le][1]?(l[le][0]=ee[le][0],l[le][1]=ee[le][1]):(l[le][0]=Number.MAX_SAFE_INTEGER,l[le][1]=0);l.sort(numericalSort);const te=h.morphAttributes.position,ie=h.morphAttributes.normal;let ne=0;for(let ce=0;ce<8;ce++){const he=l[ce],ue=he[0],de=he[1];ue!==Number.MAX_SAFE_INTEGER&&de?(te&&h.getAttribute("morphTarget"+ce)!==te[ue]&&h.setAttribute("morphTarget"+ce,te[ue]),ie&&h.getAttribute("morphNormal"+ce)!==ie[ue]&&h.setAttribute("morphNormal"+ce,ie[ue]),r[ce]=de,ne+=de):(te&&!0===h.hasAttribute("morphTarget"+ce)&&h.deleteAttribute("morphTarget"+ce),ie&&!0===h.hasAttribute("morphNormal"+ce)&&h.deleteAttribute("morphNormal"+ce),r[ce]=0)}const re=h.morphTargetsRelative?1:1-ne;d.getUniforms().setValue(e,"morphTargetBaseInfluence",re),d.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function WebGLObjects(e,t,i,n){let r=new WeakMap;function onInstancedMeshDispose(e){const t=e.target;t.removeEventListener("dispose",onInstancedMeshDispose),i.remove(t.instanceMatrix),null!==t.instanceColor&&i.remove(t.instanceColor)}return{update:function update(a){const o=n.render.frame,l=a.geometry,c=t.get(a,l);if(r.get(c)!==o&&(t.update(c),r.set(c,o)),a.isInstancedMesh&&(!1===a.hasEventListener("dispose",onInstancedMeshDispose)&&a.addEventListener("dispose",onInstancedMeshDispose),r.get(a)!==o&&(i.update(a.instanceMatrix,e.ARRAY_BUFFER),null!==a.instanceColor&&i.update(a.instanceColor,e.ARRAY_BUFFER),r.set(a,o))),a.isSkinnedMesh){const e=a.skeleton;r.get(e)!==o&&(e.update(),r.set(e,o))}return c},dispose:function dispose(){r=new WeakMap}}}const dn=new Texture$1,An=new DataArrayTexture,pn=new Data3DTexture,mn=new CubeTexture,gn=[],fn=[],vn=new Float32Array(16),En=new Float32Array(9),yn=new Float32Array(4);function flatten(e,t,i){const n=e[0];if(n<=0||n>0)return e;const r=t*i;let a=gn[r];if(void 0===a&&(a=new Float32Array(r),gn[r]=a),0!==t){n.toArray(a,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(a,r)}return a}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function copyArray(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function allocTexUnits(e,t){let i=fn[t];void 0===i&&(i=new Int32Array(t),fn[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function setValueV1f(e,t){const i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function setValueV2f(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(arraysEqual(i,t))return;e.uniform2fv(this.addr,t),copyArray(i,t)}}function setValueV3f(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(void 0!==t.r)i[0]===t.r&&i[1]===t.g&&i[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(arraysEqual(i,t))return;e.uniform3fv(this.addr,t),copyArray(i,t)}}function setValueV4f(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(arraysEqual(i,t))return;e.uniform4fv(this.addr,t),copyArray(i,t)}}function setValueM2(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(arraysEqual(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),copyArray(i,t)}else{if(arraysEqual(i,n))return;yn.set(n),e.uniformMatrix2fv(this.addr,!1,yn),copyArray(i,n)}}function setValueM3(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(arraysEqual(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),copyArray(i,t)}else{if(arraysEqual(i,n))return;En.set(n),e.uniformMatrix3fv(this.addr,!1,En),copyArray(i,n)}}function setValueM4(e,t){const i=this.cache,n=t.elements;if(void 0===n){if(arraysEqual(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),copyArray(i,t)}else{if(arraysEqual(i,n))return;vn.set(n),e.uniformMatrix4fv(this.addr,!1,vn),copyArray(i,n)}}function setValueV1i(e,t){const i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function setValueV2i(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(arraysEqual(i,t))return;e.uniform2iv(this.addr,t),copyArray(i,t)}}function setValueV3i(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(arraysEqual(i,t))return;e.uniform3iv(this.addr,t),copyArray(i,t)}}function setValueV4i(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(arraysEqual(i,t))return;e.uniform4iv(this.addr,t),copyArray(i,t)}}function setValueV1ui(e,t){const i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function setValueV2ui(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(arraysEqual(i,t))return;e.uniform2uiv(this.addr,t),copyArray(i,t)}}function setValueV3ui(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(arraysEqual(i,t))return;e.uniform3uiv(this.addr,t),copyArray(i,t)}}function setValueV4ui(e,t){const i=this.cache;if(void 0!==t.x)i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(arraysEqual(i,t))return;e.uniform4uiv(this.addr,t),copyArray(i,t)}}function setValueT1(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2D(t||dn,r)}function setValueT3D1(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(t||pn,r)}function setValueT6(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(t||mn,r)}function setValueT2DArray1(e,t,i){const n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(t||An,r)}function setValueV1fArray(e,t){e.uniform1fv(this.addr,t)}function setValueV2fArray(e,t){const i=flatten(t,this.size,2);e.uniform2fv(this.addr,i)}function setValueV3fArray(e,t){const i=flatten(t,this.size,3);e.uniform3fv(this.addr,i)}function setValueV4fArray(e,t){const i=flatten(t,this.size,4);e.uniform4fv(this.addr,i)}function setValueM2Array(e,t){const i=flatten(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function setValueM3Array(e,t){const i=flatten(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function setValueM4Array(e,t){const i=flatten(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function setValueV1iArray(e,t){e.uniform1iv(this.addr,t)}function setValueV2iArray(e,t){e.uniform2iv(this.addr,t)}function setValueV3iArray(e,t){e.uniform3iv(this.addr,t)}function setValueV4iArray(e,t){e.uniform4iv(this.addr,t)}function setValueV1uiArray(e,t){e.uniform1uiv(this.addr,t)}function setValueV2uiArray(e,t){e.uniform2uiv(this.addr,t)}function setValueV3uiArray(e,t){e.uniform3uiv(this.addr,t)}function setValueV4uiArray(e,t){e.uniform4uiv(this.addr,t)}function setValueT1Array(e,t,i){const n=this.cache,r=t.length,a=allocTexUnits(i,r);arraysEqual(n,a)||(e.uniform1iv(this.addr,a),copyArray(n,a));for(let e=0;e!==r;++e)i.setTexture2D(t[e]||dn,a[e])}function setValueT3DArray(e,t,i){const n=this.cache,r=t.length,a=allocTexUnits(i,r);arraysEqual(n,a)||(e.uniform1iv(this.addr,a),copyArray(n,a));for(let e=0;e!==r;++e)i.setTexture3D(t[e]||pn,a[e])}function setValueT6Array(e,t,i){const n=this.cache,r=t.length,a=allocTexUnits(i,r);arraysEqual(n,a)||(e.uniform1iv(this.addr,a),copyArray(n,a));for(let e=0;e!==r;++e)i.setTextureCube(t[e]||mn,a[e])}function setValueT2DArrayArray(e,t,i){const n=this.cache,r=t.length,a=allocTexUnits(i,r);arraysEqual(n,a)||(e.uniform1iv(this.addr,a),copyArray(n,a));for(let e=0;e!==r;++e)i.setTexture2DArray(t[e]||An,a[e])}class SingleUniform{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=function getSingularSetter(e){switch(e){case 5126:return setValueV1f;case 35664:return setValueV2f;case 35665:return setValueV3f;case 35666:return setValueV4f;case 35674:return setValueM2;case 35675:return setValueM3;case 35676:return setValueM4;case 5124:case 35670:return setValueV1i;case 35667:case 35671:return setValueV2i;case 35668:case 35672:return setValueV3i;case 35669:case 35673:return setValueV4i;case 5125:return setValueV1ui;case 36294:return setValueV2ui;case 36295:return setValueV3ui;case 36296:return setValueV4ui;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1;case 35679:case 36299:case 36307:return setValueT3D1;case 35680:case 36300:case 36308:case 36293:return setValueT6;case 36289:case 36303:case 36311:case 36292:return setValueT2DArray1}}(t.type)}}class PureArrayUniform{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=function getPureArraySetter(e){switch(e){case 5126:return setValueV1fArray;case 35664:return setValueV2fArray;case 35665:return setValueV3fArray;case 35666:return setValueV4fArray;case 35674:return setValueM2Array;case 35675:return setValueM3Array;case 35676:return setValueM4Array;case 5124:case 35670:return setValueV1iArray;case 35667:case 35671:return setValueV2iArray;case 35668:case 35672:return setValueV3iArray;case 35669:case 35673:return setValueV4iArray;case 5125:return setValueV1uiArray;case 36294:return setValueV2uiArray;case 36295:return setValueV3uiArray;case 36296:return setValueV4uiArray;case 35678:case 36198:case 36298:case 36306:case 35682:return setValueT1Array;case 35679:case 36299:case 36307:return setValueT3DArray;case 35680:case 36300:case 36308:case 36293:return setValueT6Array;case 36289:case 36303:case 36311:case 36292:return setValueT2DArrayArray}}(t.type)}}class StructuredUniform{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const n=this.seq;for(let r=0,a=n.length;r!==a;++r){const a=n[r];a.setValue(e,t[a.id],i)}}}const _n=/(\w+)(\])?(\[|\.)?/g;function addUniform(e,t){e.seq.push(t),e.map[t.id]=t}function parseUniform(e,t,i){const n=e.name,r=n.length;for(_n.lastIndex=0;;){const a=_n.exec(n),o=_n.lastIndex;let l=a[1];const c="]"===a[2],h=a[3];if(c&&(l|=0),void 0===h||"["===h&&o+2===r){addUniform(i,void 0===h?new SingleUniform(l,e,t):new PureArrayUniform(l,e,t));break}{let e=i.map[l];void 0===e&&(e=new StructuredUniform(l),addUniform(i,e)),i=e}}}class WebGLUniforms{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){const i=e.getActiveUniform(t,n);parseUniform(i,e.getUniformLocation(t,i.name),this)}}setValue(e,t,i,n){const r=this.map[t];void 0!==r&&r.setValue(e,i,n)}setOptional(e,t,i){const n=t[i];void 0!==n&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let r=0,a=t.length;r!==a;++r){const a=t[r],o=i[a.id];!1!==o.needsUpdate&&a.setValue(e,o.value,n)}}static seqWithValue(e,t){const i=[];for(let n=0,r=e.length;n!==r;++n){const r=e[n];r.id in t&&i.push(r)}return i}}function WebGLShader(e,t,i){const n=e.createShader(t);return e.shaderSource(n,i),e.compileShader(n),n}let xn=0;function getShaderErrors(e,t,i){const n=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(n&&""===r)return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const n=parseInt(a[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+function handleSource(e,t){const i=e.split("\n"),n=[],r=Math.max(t-6,0),a=Math.min(t+6,i.length);for(let e=r;e<a;e++){const r=e+1;n.push(`${r===t?">":" "} ${r}: ${i[e]}`)}return n.join("\n")}(e.getShaderSource(t),n)}return r}function getTexelEncodingFunction(e,t){const i=function getEncodingComponents(e){switch(e){case Ie:return["Linear","( value )"];case be:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function getToneMappingFunction(e,t){let i;switch(t){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function filterEmptyLine(e){return""!==e}function replaceLightNums(e,t){const i=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function replaceClippingPlaneNums(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Sn=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(e){return e.replace(Sn,includeReplacer)}const Cn=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function includeReplacer(e,t){let i=Ji[t];if(void 0===i){const e=Cn.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");i=Ji[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return resolveIncludes(i)}const Mn=/#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 unrollLoops(e){return e.replace(Mn,loopReplacer)}function loopReplacer(e,t,i,n){let r="";for(let e=parseInt(t);e<parseInt(i);e++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return r}function generatePrecision(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function WebGLProgram(e,t,i,n){const r=e.getContext(),a=i.defines;let o=i.vertexShader,l=i.fragmentShader;const c=function generateShadowMapTypeDefine(e){let t="SHADOWMAP_TYPE_BASIC";return 1===e.shadowMapType?t="SHADOWMAP_TYPE_PCF":2===e.shadowMapType?t="SHADOWMAP_TYPE_PCF_SOFT":3===e.shadowMapType&&(t="SHADOWMAP_TYPE_VSM"),t}(i),h=function generateEnvMapTypeDefine(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case _:case x:t="ENVMAP_TYPE_CUBE";break;case C:t="ENVMAP_TYPE_CUBE_UV"}return t}(i),d=function generateEnvMapModeDefine(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===x&&(t="ENVMAP_MODE_REFRACTION");return t}(i),A=function generateEnvMapBlendingDefine(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case 0:t="ENVMAP_BLENDING_MULTIPLY";break;case 1:t="ENVMAP_BLENDING_MIX";break;case 2:t="ENVMAP_BLENDING_ADD"}return t}(i),p=function generateCubeUVSize(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const i=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}(i),m=i.isWebGL2?"":function generateExtensions(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(filterEmptyLine).join("\n")}(i),g=function generateDefines(e){const t=[];for(const i in e){const n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}(a),f=r.createProgram();let v,E,y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(v=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g].filter(filterEmptyLine).join("\n"),v.length>0&&(v+="\n"),E=[m,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g].filter(filterEmptyLine).join("\n"),E.length>0&&(E+="\n")):(v=[generatePrecision(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g,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 "+d:"",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.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 "+c:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",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(filterEmptyLine).join("\n"),E=[m,generatePrecision(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g,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 "+h:"",i.envMap?"#define "+d:"",i.envMap?"#define "+A:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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 "+c:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?Ji.tonemapping_pars_fragment:"",0!==i.toneMapping?getToneMappingFunction("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Ji.colorspace_pars_fragment,getTexelEncodingFunction("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(filterEmptyLine).join("\n")),o=resolveIncludes(o),o=replaceLightNums(o,i),o=replaceClippingPlaneNums(o,i),l=resolveIncludes(l),l=replaceLightNums(l,i),l=replaceClippingPlaneNums(l,i),o=unrollLoops(o),l=unrollLoops(l),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(y="#version 300 es\n",v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+v,E=["#define varying in",i.glslVersion===Oe?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===Oe?"":"#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"+E);const S=y+v+o,b=y+E+l,I=WebGLShader(r,r.VERTEX_SHADER,S),T=WebGLShader(r,r.FRAGMENT_SHADER,b);if(r.attachShader(f,I),r.attachShader(f,T),void 0!==i.index0AttributeName?r.bindAttribLocation(f,0,i.index0AttributeName):!0===i.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const t=r.getProgramInfoLog(f).trim(),i=r.getShaderInfoLog(I).trim(),n=r.getShaderInfoLog(T).trim();let a=!0,o=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(a=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,f,I,T);else{const e=getShaderErrors(r,I,"vertex"),i=getShaderErrors(r,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+i)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==i&&""!==n||(o=!1);o&&(this.diagnostics={runnable:a,programLog:t,vertexShader:{log:i,prefix:v},fragmentShader:{log:n,prefix:E}})}let B,U;return r.deleteShader(I),r.deleteShader(T),this.getUniforms=function(){return void 0===B&&(B=new WebGLUniforms(r,f)),B},this.getAttributes=function(){return void 0===U&&(U=function fetchAttributeLocations(e,t){const i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const n=e.getActiveAttrib(t,r),a=n.name;let o=1;n.type===e.FLOAT_MAT2&&(o=2),n.type===e.FLOAT_MAT3&&(o=3),n.type===e.FLOAT_MAT4&&(o=4),i[a]={type:n.type,location:e.getAttribLocation(t,a),locationSize:o}}return i}(r,f)),U},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(f),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=xn++,this.cacheKey=t,this.usedTimes=1,this.program=f,this.vertexShader=I,this.fragmentShader=T,this}let bn=0;class WebGLShaderCache{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),r=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return!1===a.has(n)&&(a.add(n),n.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return void 0===i&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return void 0===i&&(i=new WebGLShaderStage(e),t.set(e,i)),i}}class WebGLShaderStage{constructor(e){this.id=bn++,this.code=e,this.usedTimes=0}}function WebGLPrograms(e,t,i,n,r,a,o){const l=new Layers,c=new WebGLShaderCache,h=[],d=r.isWebGL2,A=r.logarithmicDepthBuffer,p=r.vertexTextures;let m=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function getChannel(e){return 0===e?"uv":`uv${e}`}return{getParameters:function getParameters(a,l,h,f,v){const E=f.fog,y=v.geometry,_=a.isMeshStandardMaterial?f.environment:null,x=(a.isMeshStandardMaterial?i:t).get(a.envMap||_),S=x&&x.mapping===C?x.image.height:null,b=g[a.type];null!==a.precision&&(m=r.getMaxPrecision(a.precision),m!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",m,"instead."));const I=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=void 0!==I?I.length:0;let B,U,F,O,G=0;if(void 0!==y.morphAttributes.position&&(G=1),void 0!==y.morphAttributes.normal&&(G=2),void 0!==y.morphAttributes.color&&(G=3),b){const e=en[b];B=e.vertexShader,U=e.fragmentShader}else B=a.vertexShader,U=a.fragmentShader,c.update(a),F=c.getVertexShaderID(a),O=c.getFragmentShaderID(a);const W=e.getRenderTarget(),q=!0===v.isInstancedMesh,X=!!a.map,j=!!a.matcap,Y=!!x,K=!!a.aoMap,$=!!a.lightMap,J=!!a.bumpMap,ee=!!a.normalMap,te=!!a.displacementMap,ie=!!a.emissiveMap,ne=!!a.metalnessMap,re=!!a.roughnessMap,se=a.anisotropy>0,ae=a.clearcoat>0,oe=a.iridescence>0,le=a.sheen>0,ce=a.transmission>0,he=se&&!!a.anisotropyMap,ue=ae&&!!a.clearcoatMap,de=ae&&!!a.clearcoatNormalMap,Ae=ae&&!!a.clearcoatRoughnessMap,pe=oe&&!!a.iridescenceMap,me=oe&&!!a.iridescenceThicknessMap,ge=le&&!!a.sheenColorMap,fe=le&&!!a.sheenRoughnessMap,ve=!!a.specularMap,Ee=!!a.specularColorMap,ye=!!a.specularIntensityMap,_e=ce&&!!a.transmissionMap,xe=ce&&!!a.thicknessMap,Se=!!a.gradientMap,Ce=!!a.alphaMap,Me=a.alphaTest>0,be=!!a.alphaHash,we=!!a.extensions,Te=!!y.attributes.uv1,Be=!!y.attributes.uv2,Re=!!y.attributes.uv3;return{isWebGL2:d,shaderID:b,shaderType:a.type,shaderName:a.name,vertexShader:B,fragmentShader:U,defines:a.defines,customVertexShaderID:F,customFragmentShaderID:O,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:m,instancing:q,instancingColor:q&&null!==v.instanceColor,supportsVertexTextures:p,outputColorSpace:null===W?e.outputColorSpace:!0===W.isXRRenderTarget?W.texture.colorSpace:Ie,map:X,matcap:j,envMap:Y,envMapMode:Y&&x.mapping,envMapCubeUVHeight:S,aoMap:K,lightMap:$,bumpMap:J,normalMap:ee,displacementMap:p&&te,emissiveMap:ie,normalMapObjectSpace:ee&&1===a.normalMapType,normalMapTangentSpace:ee&&0===a.normalMapType,metalnessMap:ne,roughnessMap:re,anisotropy:se,anisotropyMap:he,clearcoat:ae,clearcoatMap:ue,clearcoatNormalMap:de,clearcoatRoughnessMap:Ae,iridescence:oe,iridescenceMap:pe,iridescenceThicknessMap:me,sheen:le,sheenColorMap:ge,sheenRoughnessMap:fe,specularMap:ve,specularColorMap:Ee,specularIntensityMap:ye,transmission:ce,transmissionMap:_e,thicknessMap:xe,gradientMap:Se,opaque:!1===a.transparent&&1===a.blending,alphaMap:Ce,alphaTest:Me,alphaHash:be,combine:a.combine,mapUv:X&&getChannel(a.map.channel),aoMapUv:K&&getChannel(a.aoMap.channel),lightMapUv:$&&getChannel(a.lightMap.channel),bumpMapUv:J&&getChannel(a.bumpMap.channel),normalMapUv:ee&&getChannel(a.normalMap.channel),displacementMapUv:te&&getChannel(a.displacementMap.channel),emissiveMapUv:ie&&getChannel(a.emissiveMap.channel),metalnessMapUv:ne&&getChannel(a.metalnessMap.channel),roughnessMapUv:re&&getChannel(a.roughnessMap.channel),anisotropyMapUv:he&&getChannel(a.anisotropyMap.channel),clearcoatMapUv:ue&&getChannel(a.clearcoatMap.channel),clearcoatNormalMapUv:de&&getChannel(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ae&&getChannel(a.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&getChannel(a.iridescenceMap.channel),iridescenceThicknessMapUv:me&&getChannel(a.iridescenceThicknessMap.channel),sheenColorMapUv:ge&&getChannel(a.sheenColorMap.channel),sheenRoughnessMapUv:fe&&getChannel(a.sheenRoughnessMap.channel),specularMapUv:ve&&getChannel(a.specularMap.channel),specularColorMapUv:Ee&&getChannel(a.specularColorMap.channel),specularIntensityMapUv:ye&&getChannel(a.specularIntensityMap.channel),transmissionMapUv:_e&&getChannel(a.transmissionMap.channel),thicknessMapUv:xe&&getChannel(a.thicknessMap.channel),alphaMapUv:Ce&&getChannel(a.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(ee||se),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUv1s:Te,vertexUv2s:Be,vertexUv3s:Re,pointsUvs:!0===v.isPoints&&!!y.attributes.uv&&(X||Ce),fog:!!E,useFog:!0===a.fog,fogExp2:E&&E.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:A,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:T,morphTextureStride:G,numDirLights:l.directional.length,numPointLights:l.point.length,numSpotLights:l.spot.length,numSpotLightMaps:l.spotLightMap.length,numRectAreaLights:l.rectArea.length,numHemiLights:l.hemi.length,numDirLightShadows:l.directionalShadowMap.length,numPointLightShadows:l.pointShadowMap.length,numSpotLightShadows:l.spotShadowMap.length,numSpotLightShadowsWithMaps:l.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:0,useLegacyLights:e.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:we&&!0===a.extensions.derivatives,extensionFragDepth:we&&!0===a.extensions.fragDepth,extensionDrawBuffers:we&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:we&&!0===a.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:a.customProgramCacheKey()}},getProgramCacheKey:function getProgramCacheKey(t){const i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.customVertexShaderID),i.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)i.push(e),i.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function getProgramCacheKeyParameters(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(i,t),function getProgramCacheKeyBooleans(e,t){l.disableAll(),t.isWebGL2&&l.enable(0);t.supportsVertexTextures&&l.enable(1);t.instancing&&l.enable(2);t.instancingColor&&l.enable(3);t.matcap&&l.enable(4);t.envMap&&l.enable(5);t.normalMapObjectSpace&&l.enable(6);t.normalMapTangentSpace&&l.enable(7);t.clearcoat&&l.enable(8);t.iridescence&&l.enable(9);t.alphaTest&&l.enable(10);t.vertexColors&&l.enable(11);t.vertexAlphas&&l.enable(12);t.vertexUv1s&&l.enable(13);t.vertexUv2s&&l.enable(14);t.vertexUv3s&&l.enable(15);t.vertexTangents&&l.enable(16);t.anisotropy&&l.enable(17);e.push(l.mask),l.disableAll(),t.fog&&l.enable(0);t.useFog&&l.enable(1);t.flatShading&&l.enable(2);t.logarithmicDepthBuffer&&l.enable(3);t.skinning&&l.enable(4);t.morphTargets&&l.enable(5);t.morphNormals&&l.enable(6);t.morphColors&&l.enable(7);t.premultipliedAlpha&&l.enable(8);t.shadowMapEnabled&&l.enable(9);t.useLegacyLights&&l.enable(10);t.doubleSided&&l.enable(11);t.flipSided&&l.enable(12);t.useDepthPacking&&l.enable(13);t.dithering&&l.enable(14);t.transmission&&l.enable(15);t.sheen&&l.enable(16);t.opaque&&l.enable(17);t.pointsUvs&&l.enable(18);e.push(l.mask)}(i,t),i.push(e.outputColorSpace)),i.push(t.customProgramCacheKey),i.join()},getUniforms:function getUniforms(e){const t=g[e.type];let i;if(t){const e=en[t];i=Wi.clone(e.uniforms)}else i=e.uniforms;return i},acquireProgram:function acquireProgram(t,i){let n;for(let e=0,t=h.length;e<t;e++){const t=h[e];if(t.cacheKey===i){n=t,++n.usedTimes;break}}return void 0===n&&(n=new WebGLProgram(e,i,t,a),h.push(n)),n},releaseProgram:function releaseProgram(e){if(0==--e.usedTimes){const t=h.indexOf(e);h[t]=h[h.length-1],h.pop(),e.destroy()}},releaseShaderCache:function releaseShaderCache(e){c.remove(e)},programs:h,dispose:function dispose(){c.dispose()}}}function WebGLProperties(){let e=new WeakMap;return{get:function get(t){let i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function remove(t){e.delete(t)},update:function update(t,i,n){e.get(t)[i]=n},dispose:function dispose(){e=new WeakMap}}}function painterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function reversePainterSortStable(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function WebGLRenderList(){const e=[];let t=0;const i=[],n=[],r=[];function getNextRenderItem(i,n,r,a,o,l){let c=e[t];return void 0===c?(c={id:i.id,object:i,geometry:n,material:r,groupOrder:a,renderOrder:i.renderOrder,z:o,group:l},e[t]=c):(c.id=i.id,c.object=i,c.geometry=n,c.material=r,c.groupOrder=a,c.renderOrder=i.renderOrder,c.z=o,c.group=l),t++,c}return{opaque:i,transmissive:n,transparent:r,init:function init(){t=0,i.length=0,n.length=0,r.length=0},push:function push(e,t,a,o,l,c){const h=getNextRenderItem(e,t,a,o,l,c);a.transmission>0?n.push(h):!0===a.transparent?r.push(h):i.push(h)},unshift:function unshift(e,t,a,o,l,c){const h=getNextRenderItem(e,t,a,o,l,c);a.transmission>0?n.unshift(h):!0===a.transparent?r.unshift(h):i.unshift(h)},finish:function finish(){for(let i=t,n=e.length;i<n;i++){const t=e[i];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function sort(e,t){i.length>1&&i.sort(e||painterSortStable),n.length>1&&n.sort(t||reversePainterSortStable),r.length>1&&r.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(){let e=new WeakMap;return{get:function get(t,i){const n=e.get(t);let r;return void 0===n?(r=new WebGLRenderList,e.set(t,[r])):i>=n.length?(r=new WebGLRenderList,n.push(r)):r=n[i],r},dispose:function dispose(){e=new WeakMap}}}function UniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new Vector3,color:new Color};break;case"SpotLight":i={position:new Vector3,direction:new Vector3,color:new Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Vector3,color:new Color,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Vector3,skyColor:new Color,groundColor:new Color};break;case"RectAreaLight":i={color:new Color,position:new Vector3,halfWidth:new Vector3,halfHeight:new Vector3}}return e[t.id]=i,i}}}let In=0;function shadowCastingAndTexturingLightsFirst(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function WebGLLights(e,t){const i=new UniformsCache,n=function ShadowUniformsCache(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.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},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};for(let e=0;e<9;e++)r.probe.push(new Vector3);const a=new Vector3,o=new Matrix4,l=new Matrix4;return{setup:function setup(a,o){let l=0,c=0,h=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let d=0,A=0,p=0,m=0,g=0,f=0,v=0,E=0,y=0,_=0;a.sort(shadowCastingAndTexturingLightsFirst);const x=!0===o?Math.PI:1;for(let e=0,t=a.length;e<t;e++){const t=a[e],o=t.color,S=t.intensity,C=t.distance,b=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)l+=o.r*S*x,c+=o.g*S*x,h+=o.b*S*x;else if(t.isLightProbe)for(let e=0;e<9;e++)r.probe[e].addScaledVector(t.sh.coefficients[e],S);else if(t.isDirectionalLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*x),t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.directionalShadow[d]=i,r.directionalShadowMap[d]=b,r.directionalShadowMatrix[d]=t.shadow.matrix,f++}r.directional[d]=e,d++}else if(t.isSpotLight){const e=i.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(o).multiplyScalar(S*x),e.distance=C,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,r.spot[p]=e;const a=t.shadow;if(t.map&&(r.spotLightMap[y]=t.map,y++,a.updateMatrices(t),t.castShadow&&_++),r.spotLightMatrix[p]=a.matrix,t.castShadow){const e=n.get(t);e.shadowBias=a.bias,e.shadowNormalBias=a.normalBias,e.shadowRadius=a.radius,e.shadowMapSize=a.mapSize,r.spotShadow[p]=e,r.spotShadowMap[p]=b,E++}p++}else if(t.isRectAreaLight){const e=i.get(t);e.color.copy(o).multiplyScalar(S),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),r.rectArea[m]=e,m++}else if(t.isPointLight){const e=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*x),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,i.shadowCameraNear=e.camera.near,i.shadowCameraFar=e.camera.far,r.pointShadow[A]=i,r.pointShadowMap[A]=b,r.pointShadowMatrix[A]=t.shadow.matrix,v++}r.point[A]=e,A++}else if(t.isHemisphereLight){const e=i.get(t);e.skyColor.copy(t.color).multiplyScalar(S*x),e.groundColor.copy(t.groundColor).multiplyScalar(S*x),r.hemi[g]=e,g++}}m>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Zi.LTC_FLOAT_1,r.rectAreaLTC2=Zi.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Zi.LTC_HALF_1,r.rectAreaLTC2=Zi.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=l,r.ambient[1]=c,r.ambient[2]=h;const S=r.hash;S.directionalLength===d&&S.pointLength===A&&S.spotLength===p&&S.rectAreaLength===m&&S.hemiLength===g&&S.numDirectionalShadows===f&&S.numPointShadows===v&&S.numSpotShadows===E&&S.numSpotMaps===y||(r.directional.length=d,r.spot.length=p,r.rectArea.length=m,r.point.length=A,r.hemi.length=g,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=v,r.pointShadowMap.length=v,r.spotShadow.length=E,r.spotShadowMap.length=E,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=v,r.spotLightMatrix.length=E+y-_,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=_,S.directionalLength=d,S.pointLength=A,S.spotLength=p,S.rectAreaLength=m,S.hemiLength=g,S.numDirectionalShadows=f,S.numPointShadows=v,S.numSpotShadows=E,S.numSpotMaps=y,r.version=In++)},setupView:function setupView(e,t){let i=0,n=0,c=0,h=0,d=0;const A=t.matrixWorldInverse;for(let t=0,p=e.length;t<p;t++){const p=e[t];if(p.isDirectionalLight){const e=r.directional[i];e.direction.setFromMatrixPosition(p.matrixWorld),a.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(A),i++}else if(p.isSpotLight){const e=r.spot[c];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(A),e.direction.setFromMatrixPosition(p.matrixWorld),a.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(A),c++}else if(p.isRectAreaLight){const e=r.rectArea[h];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(A),l.identity(),o.copy(p.matrixWorld),o.premultiply(A),l.extractRotation(o),e.halfWidth.set(.5*p.width,0,0),e.halfHeight.set(0,.5*p.height,0),e.halfWidth.applyMatrix4(l),e.halfHeight.applyMatrix4(l),h++}else if(p.isPointLight){const e=r.point[n];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(A),n++}else if(p.isHemisphereLight){const e=r.hemi[d];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(A),d++}}},state:r}}function WebGLRenderState(e,t){const i=new WebGLLights(e,t),n=[],r=[];return{init:function init(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function setupLights(e){i.setup(n,e)},setupLightsView:function setupLightsView(e){i.setupView(n,e)},pushLight:function pushLight(e){n.push(e)},pushShadow:function pushShadow(e){r.push(e)}}}function WebGLRenderStates(e,t){let i=new WeakMap;return{get:function get(n,r=0){const a=i.get(n);let o;return void 0===a?(o=new WebGLRenderState(e,t),i.set(n,[o])):r>=a.length?(o=new WebGLRenderState(e,t),a.push(o)):o=a[r],o},dispose:function dispose(){i=new WeakMap}}}class MeshDepthMaterial extends Material$1{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class MeshDistanceMaterial extends Material$1{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function WebGLShadowMap(e,t,a){let o=new Frustum;const l=new Vector2,c=new Vector2,h=new Vector4,d=new MeshDepthMaterial({depthPacking:3201}),A=new MeshDistanceMaterial,p={},m=a.maxTextureSize,g={[i]:1,[n]:0,[r]:2},f=new ShaderMaterial({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Vector2},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 <packing>\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 BufferGeometry;E.setAttribute("position",new BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Mesh(E,f),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let x=this.type;function VSMPass(i,n){const r=t.update(y);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 WebGLRenderTarget(l.x,l.y)),f.uniforms.shadow_pass.value=i.map.texture,f.uniforms.resolution.value=i.mapSize,f.uniforms.radius.value=i.radius,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(n,null,r,f,y,null),v.uniforms.shadow_pass.value=i.mapPass.texture,v.uniforms.resolution.value=i.mapSize,v.uniforms.radius.value=i.radius,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(n,null,r,v,y,null)}function getDepthMaterial(t,i,n,r){let a=null;const o=!0===n.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)a=o;else if(a=!0===n.isPointLight?A:d,e.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 e=a.uuid,t=i.uuid;let n=p[e];void 0===n&&(n={},p[e]=n);let r=n[t];void 0===r&&(r=a.clone(),n[t]=r),a=r}if(a.visible=i.visible,a.wireframe=i.wireframe,a.side=3===r?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:g[i.side],a.alphaMap=i.alphaMap,a.alphaTest=i.alphaTest,a.map=i.map,a.clipShadows=i.clipShadows,a.clippingPlanes=i.clippingPlanes,a.clipIntersection=i.clipIntersection,a.displacementMap=i.displacementMap,a.displacementScale=i.displacementScale,a.displacementBias=i.displacementBias,a.wireframeLinewidth=i.wireframeLinewidth,a.linewidth=i.linewidth,!0===n.isPointLight&&!0===a.isMeshDistanceMaterial){e.properties.get(a).light=n}return a}function renderObject(i,n,r,a,l){if(!1===i.visible)return;if(i.layers.test(n.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===l)&&(!i.frustumCulled||o.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,i.matrixWorld);const n=t.update(i),o=i.material;if(Array.isArray(o)){const t=n.groups;for(let c=0,h=t.length;c<h;c++){const h=t[c],d=o[h.materialIndex];if(d&&d.visible){const t=getDepthMaterial(i,d,a,l);e.renderBufferDirect(r,null,n,t,i,h)}}}else if(o.visible){const t=getDepthMaterial(i,o,a,l);e.renderBufferDirect(r,null,n,t,i,null)}}const c=i.children;for(let e=0,t=c.length;e<t;e++)renderObject(c[e],n,r,a,l)}this.render=function(t,i,n){if(!1===_.enabled)return;if(!1===_.autoUpdate&&!1===_.needsUpdate)return;if(0===t.length)return;const r=e.getRenderTarget(),a=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),A=e.state;A.setBlending(0),A.buffers.color.setClear(1,1,1,1),A.buffers.depth.setTest(!0),A.setScissorTest(!1);const p=3!==x&&3===this.type,g=3===x&&3!==this.type;for(let r=0,a=t.length;r<a;r++){const a=t[r],d=a.shadow;if(void 0===d){console.warn("THREE.WebGLShadowMap:",a,"has no shadow.");continue}if(!1===d.autoUpdate&&!1===d.needsUpdate)continue;l.copy(d.mapSize);const f=d.getFrameExtents();if(l.multiply(f),c.copy(d.mapSize),(l.x>m||l.y>m)&&(l.x>m&&(c.x=Math.floor(m/f.x),l.x=c.x*f.x,d.mapSize.x=c.x),l.y>m&&(c.y=Math.floor(m/f.y),l.y=c.y*f.y,d.mapSize.y=c.y)),null===d.map||!0===p||!0===g){const e=3!==this.type?{minFilter:B,magFilter:B}:{};null!==d.map&&d.map.dispose(),d.map=new WebGLRenderTarget(l.x,l.y,e),d.map.texture.name=a.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const v=d.getViewportCount();for(let e=0;e<v;e++){const t=d.getViewport(e);h.set(c.x*t.x,c.y*t.y,c.x*t.z,c.y*t.w),A.viewport(h),d.updateMatrices(a,e),o=d.getFrustum(),renderObject(i,n,d.camera,a,this.type)}!0!==d.isPointLightShadow&&3===this.type&&VSMPass(d,n),d.needsUpdate=!1}x=this.type,_.needsUpdate=!1,e.setRenderTarget(r,a,d)}}function WebGLState(e,t,i){const n=i.isWebGL2;const r=new function ColorBuffer(){let t=!1;const i=new Vector4;let n=null;const r=new Vector4(0,0,0,0);return{setMask:function(i){n===i||t||(e.colorMask(i,i,i,i),n=i)},setLocked:function(e){t=e},setClear:function(t,n,a,o,l){!0===l&&(t*=o,n*=o,a*=o),i.set(t,n,a,o),!1===r.equals(i)&&(e.clearColor(t,n,a,o),r.copy(i))},reset:function(){t=!1,n=null,r.set(-1,0,0,0)}}},_=new function DepthBuffer(){let t=!1,i=null,n=null,r=null;return{setTest:function(t){t?enable(e.DEPTH_TEST):disable(e.DEPTH_TEST)},setMask:function(n){i===n||t||(e.depthMask(n),i=n)},setFunc:function(t){if(n!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:default:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL)}n=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,i=null,n=null,r=null}}},x=new function StencilBuffer(){let t=!1,i=null,n=null,r=null,a=null,o=null,l=null,c=null,h=null;return{setTest:function(i){t||(i?enable(e.STENCIL_TEST):disable(e.STENCIL_TEST))},setMask:function(n){i===n||t||(e.stencilMask(n),i=n)},setFunc:function(t,i,o){n===t&&r===i&&a===o||(e.stencilFunc(t,i,o),n=t,r=i,a=o)},setOp:function(t,i,n){o===t&&l===i&&c===n||(e.stencilOp(t,i,n),o=t,l=i,c=n)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,i=null,n=null,r=null,a=null,o=null,l=null,c=null,h=null}}},S=new WeakMap,C=new WeakMap;let b={},I={},T=new WeakMap,B=[],U=null,F=!1,O=null,G=null,W=null,q=null,X=null,j=null,Y=null,K=!1,$=null,J=null,ee=null,te=null,ie=null;const ne=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let re=!1,se=0;const ae=e.getParameter(e.VERSION);-1!==ae.indexOf("WebGL")?(se=parseFloat(/^WebGL (\d)/.exec(ae)[1]),re=se>=1):-1!==ae.indexOf("OpenGL ES")&&(se=parseFloat(/^OpenGL ES (\d)/.exec(ae)[1]),re=se>=2);let oe=null,le={};const ce=e.getParameter(e.SCISSOR_BOX),he=e.getParameter(e.VIEWPORT),ue=(new Vector4).fromArray(ce),de=(new Vector4).fromArray(he);function createTexture(t,i,r,a){const o=new Uint8Array(4),l=e.createTexture();e.bindTexture(t,l),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let l=0;l<r;l++)!n||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(i+l,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,o):e.texImage3D(i,0,e.RGBA,1,1,a,0,e.RGBA,e.UNSIGNED_BYTE,o);return l}const Ae={};function enable(t){!0!==b[t]&&(e.enable(t),b[t]=!0)}function disable(t){!1!==b[t]&&(e.disable(t),b[t]=!1)}Ae[e.TEXTURE_2D]=createTexture(e.TEXTURE_2D,e.TEXTURE_2D,1),Ae[e.TEXTURE_CUBE_MAP]=createTexture(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(Ae[e.TEXTURE_2D_ARRAY]=createTexture(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),Ae[e.TEXTURE_3D]=createTexture(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),r.setClear(0,0,0,1),_.setClear(1),x.setClear(0),enable(e.DEPTH_TEST),_.setFunc(3),setFlipSided(!1),setCullFace(1),enable(e.CULL_FACE),setBlending(0);const pe={[a]:e.FUNC_ADD,[o]:e.FUNC_SUBTRACT,[l]:e.FUNC_REVERSE_SUBTRACT};if(n)pe[103]=e.MIN,pe[104]=e.MAX;else{const e=t.get("EXT_blend_minmax");null!==e&&(pe[103]=e.MIN_EXT,pe[104]=e.MAX_EXT)}const me={[c]:e.ZERO,[h]:e.ONE,[d]:e.SRC_COLOR,[p]:e.SRC_ALPHA,[y]:e.SRC_ALPHA_SATURATE,[v]:e.DST_COLOR,[g]:e.DST_ALPHA,[A]:e.ONE_MINUS_SRC_COLOR,[m]:e.ONE_MINUS_SRC_ALPHA,[E]:e.ONE_MINUS_DST_COLOR,[f]:e.ONE_MINUS_DST_ALPHA};function setBlending(t,i,n,r,o,l,c,h){if(0!==t){if(!1===F&&(enable(e.BLEND),F=!0),5===t)o=o||i,l=l||n,c=c||r,i===G&&o===X||(e.blendEquationSeparate(pe[i],pe[o]),G=i,X=o),n===W&&r===q&&l===j&&c===Y||(e.blendFuncSeparate(me[n],me[r],me[l],me[c]),W=n,q=r,j=l,Y=c),O=t,K=!1;else if(t!==O||h!==K){if(G===a&&X===a||(e.blendEquation(e.FUNC_ADD),G=a,X=a),h)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}W=null,q=null,j=null,Y=null,O=t,K=h}}else!0===F&&(disable(e.BLEND),F=!1)}function setFlipSided(t){$!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),$=t)}function setCullFace(t){0!==t?(enable(e.CULL_FACE),t!==J&&(1===t?e.cullFace(e.BACK):2===t?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):disable(e.CULL_FACE),J=t}function setPolygonOffset(t,i,n){t?(enable(e.POLYGON_OFFSET_FILL),te===i&&ie===n||(e.polygonOffset(i,n),te=i,ie=n)):disable(e.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:_,stencil:x},enable,disable,bindFramebuffer:function bindFramebuffer(t,i){return I[t]!==i&&(e.bindFramebuffer(t,i),I[t]=i,n&&(t===e.DRAW_FRAMEBUFFER&&(I[e.FRAMEBUFFER]=i),t===e.FRAMEBUFFER&&(I[e.DRAW_FRAMEBUFFER]=i)),!0)},drawBuffers:function drawBuffers(n,r){let a=B,o=!1;if(n)if(a=T.get(r),void 0===a&&(a=[],T.set(r,a)),n.isWebGLMultipleRenderTargets){const t=n.texture;if(a.length!==t.length||a[0]!==e.COLOR_ATTACHMENT0){for(let i=0,n=t.length;i<n;i++)a[i]=e.COLOR_ATTACHMENT0+i;a.length=t.length,o=!0}}else a[0]!==e.COLOR_ATTACHMENT0&&(a[0]=e.COLOR_ATTACHMENT0,o=!0);else a[0]!==e.BACK&&(a[0]=e.BACK,o=!0);o&&(i.isWebGL2?e.drawBuffers(a):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function useProgram(t){return U!==t&&(e.useProgram(t),U=t,!0)},setBlending,setMaterial:function setMaterial(t,i){2===t.side?disable(e.CULL_FACE):enable(e.CULL_FACE);let n=1===t.side;i&&(n=!n),setFlipSided(n),1===t.blending&&!1===t.transparent?setBlending(0):setBlending(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),_.setFunc(t.depthFunc),_.setTest(t.depthTest),_.setMask(t.depthWrite),r.setMask(t.colorWrite);const a=t.stencilWrite;x.setTest(a),a&&(x.setMask(t.stencilWriteMask),x.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),x.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),setPolygonOffset(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?enable(e.SAMPLE_ALPHA_TO_COVERAGE):disable(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided,setCullFace,setLineWidth:function setLineWidth(t){t!==ee&&(re&&e.lineWidth(t),ee=t)},setPolygonOffset,setScissorTest:function setScissorTest(t){t?enable(e.SCISSOR_TEST):disable(e.SCISSOR_TEST)},activeTexture:function activeTexture(t){void 0===t&&(t=e.TEXTURE0+ne-1),oe!==t&&(e.activeTexture(t),oe=t)},bindTexture:function bindTexture(t,i,n){void 0===n&&(n=null===oe?e.TEXTURE0+ne-1:oe);let r=le[n];void 0===r&&(r={type:void 0,texture:void 0},le[n]=r),r.type===t&&r.texture===i||(oe!==n&&(e.activeTexture(n),oe=n),e.bindTexture(t,i||Ae[t]),r.type=t,r.texture=i)},unbindTexture:function unbindTexture(){const t=le[oe];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function compressedTexImage2D(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function compressedTexImage3D(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function texImage2D(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function texImage3D(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function updateUBOMapping(t,i){let n=C.get(i);void 0===n&&(n=new WeakMap,C.set(i,n));let r=n.get(t);void 0===r&&(r=e.getUniformBlockIndex(i,t.name),n.set(t,r))},uniformBlockBinding:function uniformBlockBinding(t,i){const n=C.get(i).get(t);S.get(i)!==n&&(e.uniformBlockBinding(i,n,t.__bindingPointIndex),S.set(i,n))},texStorage2D:function texStorage2D(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function texStorage3D(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function texSubImage2D(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function texSubImage3D(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function compressedTexSubImage2D(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function compressedTexSubImage3D(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function scissor(t){!1===ue.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),ue.copy(t))},viewport:function viewport(t){!1===de.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),de.copy(t))},reset:function reset(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),!0===n&&(e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),b={},oe=null,le={},I={},T=new WeakMap,B=[],U=null,F=!1,O=null,G=null,W=null,q=null,X=null,j=null,Y=null,K=!1,$=null,J=null,ee=null,te=null,ie=null,ue.set(0,0,e.canvas.width,e.canvas.height),de.set(0,0,e.canvas.width,e.canvas.height),r.reset(),_.reset(),x.reset()}}}function WebGLTextures(e,t,i,n,r,a,o){const l=r.isWebGL2,c=r.maxTextures,h=r.maxCubemapSize,d=r.maxTextureSize,A=r.maxSamples,p=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,m="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap;let f;const v=new WeakMap;let E=!1;try{E="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function createCanvas(e,t){return E?new OffscreenCanvas(e,t):createElementNS("canvas")}function resizeImage(e,t,i,n){let r=1;if((e.width>n||e.height>n)&&(r=n/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const n=t?floorPowerOfTwo:Math.floor,a=n(r*e.width),o=n(r*e.height);void 0===f&&(f=createCanvas(a,o));const l=i?createCanvas(a,o):f;l.width=a,l.height=o;return l.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+o+")."),l}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function isPowerOfTwo$1(e){return isPowerOfTwo(e.width)&&isPowerOfTwo(e.height)}function textureNeedsGenerateMipmaps(e,t){return e.generateMipmaps&&t&&e.minFilter!==B&&e.minFilter!==O}function generateMipmap(t){e.generateMipmap(t)}function getInternalFormat(i,n,r,a,o=!1){if(!1===l)return n;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let c=n;return n===e.RED&&(r===e.FLOAT&&(c=e.R32F),r===e.HALF_FLOAT&&(c=e.R16F),r===e.UNSIGNED_BYTE&&(c=e.R8)),n===e.RG&&(r===e.FLOAT&&(c=e.RG32F),r===e.HALF_FLOAT&&(c=e.RG16F),r===e.UNSIGNED_BYTE&&(c=e.RG8)),n===e.RGBA&&(r===e.FLOAT&&(c=e.RGBA32F),r===e.HALF_FLOAT&&(c=e.RGBA16F),r===e.UNSIGNED_BYTE&&(c=a===be&&!1===o?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)),c!==e.R16F&&c!==e.R32F&&c!==e.RG16F&&c!==e.RG32F&&c!==e.RGBA16F&&c!==e.RGBA32F||t.get("EXT_color_buffer_float"),c}function getMipLevels(e,t,i){return!0===textureNeedsGenerateMipmaps(e,i)||e.isFramebufferTexture&&e.minFilter!==B&&e.minFilter!==O?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function filterFallback(t){return t===B||t===U||t===F?e.NEAREST:e.LINEAR}function onTextureDispose(e){const t=e.target;t.removeEventListener("dispose",onTextureDispose),function deallocateTexture(e){const t=n.get(e);if(void 0===t.__webglInit)return;const i=e.source,r=v.get(i);if(r){const n=r[t.__cacheKey];n.usedTimes--,0===n.usedTimes&&deleteTexture(e),0===Object.keys(r).length&&v.delete(i)}n.remove(e)}(t),t.isVideoTexture&&g.delete(t)}function onRenderTargetDispose(t){const i=t.target;i.removeEventListener("dispose",onRenderTargetDispose),function deallocateRenderTarget(t){const i=t.texture,r=n.get(t),a=n.get(i);void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),o.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t<r.__webglColorRenderbuffer.length;t++)r.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(r.__webglColorRenderbuffer[t]);r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);r.__webglTexture&&(e.deleteTexture(r.__webglTexture),o.memory.textures--),n.remove(i[t])}n.remove(i),n.remove(t)}(i)}function deleteTexture(t){const i=n.get(t);e.deleteTexture(i.__webglTexture);const r=t.source;delete v.get(r)[i.__cacheKey],o.memory.textures--}let y=0;function setTexture2D(t,r){const a=n.get(t);if(t.isVideoTexture&&function updateVideoTexture(e){const t=o.render.frame;g.get(e)!==t&&(g.set(e,t),e.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void uploadTexture(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}const _={[b]:e.REPEAT,[I]:e.CLAMP_TO_EDGE,[T]:e.MIRRORED_REPEAT},x={[B]:e.NEAREST,[U]:e.NEAREST_MIPMAP_NEAREST,[F]:e.NEAREST_MIPMAP_LINEAR,[O]:e.LINEAR,[G]:e.LINEAR_MIPMAP_NEAREST,[W]:e.LINEAR_MIPMAP_LINEAR},S={[Be]:e.NEVER,[Ne]:e.ALWAYS,[Re]:e.LESS,[De]:e.LEQUAL,[Le]:e.EQUAL,[Fe]:e.GEQUAL,[Ue]:e.GREATER,[Pe]:e.NOTEQUAL};function setTextureParameters(i,a,o){if(o?(e.texParameteri(i,e.TEXTURE_WRAP_S,_[a.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,_[a.wrapT]),i!==e.TEXTURE_3D&&i!==e.TEXTURE_2D_ARRAY||e.texParameteri(i,e.TEXTURE_WRAP_R,_[a.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,x[a.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,x[a.minFilter])):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i!==e.TEXTURE_3D&&i!==e.TEXTURE_2D_ARRAY||e.texParameteri(i,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),a.wrapS===I&&a.wrapT===I||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,e.TEXTURE_MAG_FILTER,filterFallback(a.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,filterFallback(a.minFilter)),a.minFilter!==B&&a.minFilter!==O&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),a.compareFunction&&(e.texParameteri(i,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(i,e.TEXTURE_COMPARE_FUNC,S[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const o=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===B)return;if(a.minFilter!==F&&a.minFilter!==W)return;if(a.type===K&&!1===t.has("OES_texture_float_linear"))return;if(!1===l&&a.type===$&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||n.get(a).__currentAnisotropy)&&(e.texParameterf(i,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function initTexture(t,i){let n=!1;void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",onTextureDispose));const r=i.source;let a=v.get(r);void 0===a&&(a={},v.set(r,a));const l=function getTextureCacheKey(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(i);if(l!==t.__cacheKey){void 0===a[l]&&(a[l]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,n=!0),a[l].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&deleteTexture(i)),t.__cacheKey=l,t.__webglTexture=a[l].texture}return n}function uploadTexture(t,r,o){let c=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(c=e.TEXTURE_3D);const h=initTexture(t,r),A=r.source;i.bindTexture(c,t.__webglTexture,e.TEXTURE0+o);const p=n.get(A);if(A.version!==p.__version||!0===h){i.activeTexture(e.TEXTURE0+o),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=function textureNeedsPowerOfTwo(e){return!l&&(e.wrapS!==I||e.wrapT!==I||e.minFilter!==B&&e.minFilter!==O)}(r)&&!1===isPowerOfTwo$1(r.image);let n=resizeImage(r.image,t,!1,d);n=verifyColorSpace(r,n);const m=isPowerOfTwo$1(n)||l,g=a.convert(r.format,r.colorSpace);let f,v=a.convert(r.type),E=getInternalFormat(r.internalFormat,g,v,r.colorSpace);setTextureParameters(c,r,m);const y=r.mipmaps,_=l&&!0!==r.isVideoTexture,x=void 0===p.__version||!0===h,S=getMipLevels(r,n,m);if(r.isDepthTexture)E=e.DEPTH_COMPONENT,l?E=r.type===K?e.DEPTH_COMPONENT32F:r.type===Y?e.DEPTH_COMPONENT24:r.type===J?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===K&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===te&&E===e.DEPTH_COMPONENT&&r.type!==X&&r.type!==Y&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Y,v=a.convert(r.type)),r.format===ie&&E===e.DEPTH_COMPONENT&&(E=e.DEPTH_STENCIL,r.type!==J&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=J,v=a.convert(r.type))),x&&(_?i.texStorage2D(e.TEXTURE_2D,1,E,n.width,n.height):i.texImage2D(e.TEXTURE_2D,0,E,n.width,n.height,0,g,v,null));else if(r.isDataTexture)if(y.length>0&&m){_&&x&&i.texStorage2D(e.TEXTURE_2D,S,E,y[0].width,y[0].height);for(let t=0,n=y.length;t<n;t++)f=y[t],_?i.texSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,g,v,f.data):i.texImage2D(e.TEXTURE_2D,t,E,f.width,f.height,0,g,v,f.data);r.generateMipmaps=!1}else _?(x&&i.texStorage2D(e.TEXTURE_2D,S,E,n.width,n.height),i.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,g,v,n.data)):i.texImage2D(e.TEXTURE_2D,0,E,n.width,n.height,0,g,v,n.data);else if(r.isCompressedTexture)if(r.isCompressedArrayTexture){_&&x&&i.texStorage3D(e.TEXTURE_2D_ARRAY,S,E,y[0].width,y[0].height,n.depth);for(let t=0,a=y.length;t<a;t++)f=y[t],r.format!==ee?null!==g?_?i.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,f.width,f.height,n.depth,g,f.data,0,0):i.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,E,f.width,f.height,n.depth,0,f.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):_?i.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,f.width,f.height,n.depth,g,v,f.data):i.texImage3D(e.TEXTURE_2D_ARRAY,t,E,f.width,f.height,n.depth,0,g,v,f.data)}else{_&&x&&i.texStorage2D(e.TEXTURE_2D,S,E,y[0].width,y[0].height);for(let t=0,n=y.length;t<n;t++)f=y[t],r.format!==ee?null!==g?_?i.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,g,f.data):i.compressedTexImage2D(e.TEXTURE_2D,t,E,f.width,f.height,0,f.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):_?i.texSubImage2D(e.TEXTURE_2D,t,0,0,f.width,f.height,g,v,f.data):i.texImage2D(e.TEXTURE_2D,t,E,f.width,f.height,0,g,v,f.data)}else if(r.isDataArrayTexture)_?(x&&i.texStorage3D(e.TEXTURE_2D_ARRAY,S,E,n.width,n.height,n.depth),i.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,n.width,n.height,n.depth,g,v,n.data)):i.texImage3D(e.TEXTURE_2D_ARRAY,0,E,n.width,n.height,n.depth,0,g,v,n.data);else if(r.isData3DTexture)_?(x&&i.texStorage3D(e.TEXTURE_3D,S,E,n.width,n.height,n.depth),i.texSubImage3D(e.TEXTURE_3D,0,0,0,0,n.width,n.height,n.depth,g,v,n.data)):i.texImage3D(e.TEXTURE_3D,0,E,n.width,n.height,n.depth,0,g,v,n.data);else if(r.isFramebufferTexture){if(x)if(_)i.texStorage2D(e.TEXTURE_2D,S,E,n.width,n.height);else{let t=n.width,r=n.height;for(let n=0;n<S;n++)i.texImage2D(e.TEXTURE_2D,n,E,t,r,0,g,v,null),t>>=1,r>>=1}}else if(y.length>0&&m){_&&x&&i.texStorage2D(e.TEXTURE_2D,S,E,y[0].width,y[0].height);for(let t=0,n=y.length;t<n;t++)f=y[t],_?i.texSubImage2D(e.TEXTURE_2D,t,0,0,g,v,f):i.texImage2D(e.TEXTURE_2D,t,E,g,v,f);r.generateMipmaps=!1}else _?(x&&i.texStorage2D(e.TEXTURE_2D,S,E,n.width,n.height),i.texSubImage2D(e.TEXTURE_2D,0,0,0,g,v,n)):i.texImage2D(e.TEXTURE_2D,0,E,g,v,n);textureNeedsGenerateMipmaps(r,m)&&generateMipmap(c),p.__version=A.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function setupFrameBufferTexture(t,r,o,l,c){const h=a.convert(o.format,o.colorSpace),d=a.convert(o.type),A=getInternalFormat(o.internalFormat,h,d,o.colorSpace);n.get(r).__hasExternalTextures||(c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?i.texImage3D(c,0,A,r.width,r.height,r.depth,0,h,d,null):i.texImage2D(c,0,A,r.width,r.height,0,h,d,null)),i.bindFramebuffer(e.FRAMEBUFFER,t),useMultisampledRTT(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,c,n.get(o).__webglTexture,0,getRenderTargetSamples(r)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,c,n.get(o).__webglTexture,0),i.bindFramebuffer(e.FRAMEBUFFER,null)}function setupRenderBufferStorage(t,i,n){if(e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer&&!i.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(n||useMultisampledRTT(i)){const t=i.depthTexture;t&&t.isDepthTexture&&(t.type===K?r=e.DEPTH_COMPONENT32F:t.type===Y&&(r=e.DEPTH_COMPONENT24));const n=getRenderTargetSamples(i);useMultisampledRTT(i)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,n,r,i.width,i.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,n,r,i.width,i.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,i.width,i.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(i.depthBuffer&&i.stencilBuffer){const r=getRenderTargetSamples(i);n&&!1===useMultisampledRTT(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,i.width,i.height):useMultisampledRTT(i)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let r=0;r<t.length;r++){const o=t[r],l=a.convert(o.format,o.colorSpace),c=a.convert(o.type),h=getInternalFormat(o.internalFormat,l,c,o.colorSpace),d=getRenderTargetSamples(i);n&&!1===useMultisampledRTT(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,d,h,i.width,i.height):useMultisampledRTT(i)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,d,h,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,h,i.width,i.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function setupDepthRenderbuffer(t){const r=n.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function setupDepthTexture(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");n.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),setTexture2D(r.depthTexture,0);const a=n.get(r.depthTexture).__webglTexture,o=getRenderTargetSamples(r);if(r.depthTexture.format===te)useMultisampledRTT(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0,o):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,a,0);else{if(r.depthTexture.format!==ie)throw new Error("Unknown depthTexture format");useMultisampledRTT(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0,o):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,a,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let n=0;n<6;n++)i.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=e.createRenderbuffer(),setupRenderBufferStorage(r.__webglDepthbuffer[n],t,!1)}else i.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),setupRenderBufferStorage(r.__webglDepthbuffer,t,!1);i.bindFramebuffer(e.FRAMEBUFFER,null)}function getRenderTargetSamples(e){return Math.min(A,e.samples)}function useMultisampledRTT(e){const i=n.get(e);return l&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function verifyColorSpace(e,i){const n=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||e.format===ke||n!==Ie&&n!==Me&&(n===be?!1===l?!0===t.has("EXT_sRGB")&&r===ee?(e.format=ke,e.minFilter=O,e.generateMipmaps=!1):i=ImageUtils.sRGBToLinear(i):r===ee&&a===q||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 allocateTextureUnit(){const e=y;return e>=c&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+c),y+=1,e},this.resetTextureUnits=function resetTextureUnits(){y=0},this.setTexture2D=setTexture2D,this.setTexture2DArray=function setTexture2DArray(t,r){const a=n.get(t);t.version>0&&a.__version!==t.version?uploadTexture(a,t,r):i.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function setTexture3D(t,r){const a=n.get(t);t.version>0&&a.__version!==t.version?uploadTexture(a,t,r):i.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function setTextureCube(t,r){const o=n.get(t);t.version>0&&o.__version!==t.version?function uploadCubeTexture(t,r,o){if(6!==r.image.length)return;const c=initTexture(t,r),d=r.source;i.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const A=n.get(d);if(d.version!==A.__version||!0===c){i.activeTexture(e.TEXTURE0+o),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,n=r.image[0]&&r.image[0].isDataTexture,p=[];for(let e=0;e<6;e++)p[e]=t||n?n?r.image[e].image:r.image[e]:resizeImage(r.image[e],!1,!0,h),p[e]=verifyColorSpace(r,p[e]);const m=p[0],g=isPowerOfTwo$1(m)||l,f=a.convert(r.format,r.colorSpace),v=a.convert(r.type),E=getInternalFormat(r.internalFormat,f,v,r.colorSpace),y=l&&!0!==r.isVideoTexture,_=void 0===A.__version||!0===c;let x,S=getMipLevels(r,m,g);if(setTextureParameters(e.TEXTURE_CUBE_MAP,r,g),t){y&&_&&i.texStorage2D(e.TEXTURE_CUBE_MAP,S,E,m.width,m.height);for(let t=0;t<6;t++){x=p[t].mipmaps;for(let n=0;n<x.length;n++){const a=x[n];r.format!==ee?null!==f?y?i.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,a.width,a.height,f,a.data):i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,E,a.width,a.height,0,a.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):y?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,a.width,a.height,f,v,a.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,E,a.width,a.height,0,f,v,a.data)}}}else{x=r.mipmaps,y&&_&&(x.length>0&&S++,i.texStorage2D(e.TEXTURE_CUBE_MAP,S,E,p[0].width,p[0].height));for(let t=0;t<6;t++)if(n){y?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,p[t].width,p[t].height,f,v,p[t].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,p[t].width,p[t].height,0,f,v,p[t].data);for(let n=0;n<x.length;n++){const r=x[n].image[t].image;y?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,r.width,r.height,f,v,r.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,E,r.width,r.height,0,f,v,r.data)}}else{y?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f,v,p[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,f,v,p[t]);for(let n=0;n<x.length;n++){const r=x[n];y?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,f,v,r.image[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,E,f,v,r.image[t])}}}textureNeedsGenerateMipmaps(r,g)&&generateMipmap(e.TEXTURE_CUBE_MAP),A.__version=d.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}(o,t,r):i.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture,e.TEXTURE0+r)},this.rebindTextures=function rebindTextures(t,i,r){const a=n.get(t);void 0!==i&&setupFrameBufferTexture(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),void 0!==r&&setupDepthRenderbuffer(t)},this.setupRenderTarget=function setupRenderTarget(t){const c=t.texture,h=n.get(t),d=n.get(c);t.addEventListener("dispose",onRenderTargetDispose),!0!==t.isWebGLMultipleRenderTargets&&(void 0===d.__webglTexture&&(d.__webglTexture=e.createTexture()),d.__version=c.version,o.memory.textures++);const A=!0===t.isWebGLCubeRenderTarget,p=!0===t.isWebGLMultipleRenderTargets,m=isPowerOfTwo$1(t)||l;if(A){h.__webglFramebuffer=[];for(let t=0;t<6;t++)h.__webglFramebuffer[t]=e.createFramebuffer()}else{if(h.__webglFramebuffer=e.createFramebuffer(),p)if(r.drawBuffers){const i=t.texture;for(let t=0,r=i.length;t<r;t++){const r=n.get(i[t]);void 0===r.__webglTexture&&(r.__webglTexture=e.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&t.samples>0&&!1===useMultisampledRTT(t)){const n=p?c:[c];h.__webglMultisampledFramebuffer=e.createFramebuffer(),h.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let i=0;i<n.length;i++){const r=n[i];h.__webglColorRenderbuffer[i]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,h.__webglColorRenderbuffer[i]);const o=a.convert(r.format,r.colorSpace),l=a.convert(r.type),c=getInternalFormat(r.internalFormat,o,l,r.colorSpace,!0===t.isXRRenderTarget),d=getRenderTargetSamples(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,d,c,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+i,e.RENDERBUFFER,h.__webglColorRenderbuffer[i])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(h.__webglDepthRenderbuffer=e.createRenderbuffer(),setupRenderBufferStorage(h.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(e.FRAMEBUFFER,null)}}if(A){i.bindTexture(e.TEXTURE_CUBE_MAP,d.__webglTexture),setTextureParameters(e.TEXTURE_CUBE_MAP,c,m);for(let i=0;i<6;i++)setupFrameBufferTexture(h.__webglFramebuffer[i],t,c,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i);textureNeedsGenerateMipmaps(c,m)&&generateMipmap(e.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(p){const r=t.texture;for(let a=0,o=r.length;a<o;a++){const o=r[a],l=n.get(o);i.bindTexture(e.TEXTURE_2D,l.__webglTexture),setTextureParameters(e.TEXTURE_2D,o,m),setupFrameBufferTexture(h.__webglFramebuffer,t,o,e.COLOR_ATTACHMENT0+a,e.TEXTURE_2D),textureNeedsGenerateMipmaps(o,m)&&generateMipmap(e.TEXTURE_2D)}i.unbindTexture()}else{let n=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l?n=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(n,d.__webglTexture),setTextureParameters(n,c,m),setupFrameBufferTexture(h.__webglFramebuffer,t,c,e.COLOR_ATTACHMENT0,n),textureNeedsGenerateMipmaps(c,m)&&generateMipmap(n),i.unbindTexture()}t.depthBuffer&&setupDepthRenderbuffer(t)},this.updateRenderTargetMipmap=function updateRenderTargetMipmap(t){const r=isPowerOfTwo$1(t)||l,a=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let o=0,l=a.length;o<l;o++){const l=a[o];if(textureNeedsGenerateMipmaps(l,r)){const r=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=n.get(l).__webglTexture;i.bindTexture(r,a),generateMipmap(r),i.unbindTexture()}}},this.updateMultisampleRenderTarget=function updateMultisampleRenderTarget(t){if(l&&t.samples>0&&!1===useMultisampledRTT(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,o=t.height;let l=e.COLOR_BUFFER_BIT;const c=[],h=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,d=n.get(t),A=!0===t.isWebGLMultipleRenderTargets;if(A)for(let t=0;t<r.length;t++)i.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),i.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);i.bindFramebuffer(e.READ_FRAMEBUFFER,d.__webglMultisampledFramebuffer),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer);for(let i=0;i<r.length;i++){c.push(e.COLOR_ATTACHMENT0+i),t.depthBuffer&&c.push(h);const p=void 0!==d.__ignoreDepthValues&&d.__ignoreDepthValues;if(!1===p&&(t.depthBuffer&&(l|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(l|=e.STENCIL_BUFFER_BIT)),A&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,d.__webglColorRenderbuffer[i]),!0===p&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[h]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[h])),A){const t=n.get(r[i]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,l,e.NEAREST),m&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,c)}if(i.bindFramebuffer(e.READ_FRAMEBUFFER,null),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),A)for(let t=0;t<r.length;t++){i.bindFramebuffer(e.FRAMEBUFFER,d.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,d.__webglColorRenderbuffer[t]);const a=n.get(r[t]).__webglTexture;i.bindFramebuffer(e.FRAMEBUFFER,d.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}i.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=setupDepthRenderbuffer,this.setupFrameBufferTexture=setupFrameBufferTexture,this.useMultisampledRTT=useMultisampledRTT}function WebGLUtils(e,t,i){const n=i.isWebGL2;return{convert:function convert(i,r=""){let a;if(i===q)return e.UNSIGNED_BYTE;if(1017===i)return e.UNSIGNED_SHORT_4_4_4_4;if(1018===i)return e.UNSIGNED_SHORT_5_5_5_1;if(1010===i)return e.BYTE;if(1011===i)return e.SHORT;if(i===X)return e.UNSIGNED_SHORT;if(i===j)return e.INT;if(i===Y)return e.UNSIGNED_INT;if(i===K)return e.FLOAT;if(i===$)return n?e.HALF_FLOAT:(a=t.get("OES_texture_half_float"),null!==a?a.HALF_FLOAT_OES:null);if(1021===i)return e.ALPHA;if(i===ee)return e.RGBA;if(1024===i)return e.LUMINANCE;if(1025===i)return e.LUMINANCE_ALPHA;if(i===te)return e.DEPTH_COMPONENT;if(i===ie)return e.DEPTH_STENCIL;if(i===ke)return a=t.get("EXT_sRGB"),null!==a?a.SRGB_ALPHA_EXT:null;if(i===ne)return e.RED;if(1029===i)return e.RED_INTEGER;if(i===re)return e.RG;if(1031===i)return e.RG_INTEGER;if(1033===i)return e.RGBA_INTEGER;if(i===se||i===ae||i===oe||i===le)if(r===be){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(i===se)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ae)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===oe)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===le)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(i===se)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ae)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===oe)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===le)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===ce||35841===i||i===he||35843===i){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(i===ce)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===i)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===he)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===i)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===i)return a=t.get("WEBGL_compressed_texture_etc1"),null!==a?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===ue||i===de){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(i===ue)return r===be?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===de)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}if(i===Ae||37809===i||37810===i||37811===i||37812===i||37813===i||37814===i||37815===i||37816===i||37817===i||37818===i||37819===i||37820===i||37821===i){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(i===Ae)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===i)return r===be?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===pe){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(i===pe)return r===be?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(36283===i||36284===i||36285===i||36286===i){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(i===pe)return a.COMPRESSED_RED_RGTC1_EXT;if(36284===i)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===i)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===i)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===J?n?e.UNSIGNED_INT_24_8:(a=t.get("WEBGL_depth_texture"),null!==a?a.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[i]?e[i]:null}}}class ArrayCamera extends PerspectiveCamera{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Group extends Object3D{constructor(){super(),this.isGroup=!0,this.type="Group"}}const wn={type:"move"};class WebXRController{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Group,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Vector3),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Vector3),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,i){let n=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(c&&e.hand){a=!0;for(const n of e.hand.values()){const e=t.getJointPose(n,i),r=this._getHandJoint(c,n);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}const n=c.joints["index-finger-tip"],r=c.joints["thumb-tip"],o=n.position.distanceTo(r.position),l=.02,h=.005;c.inputState.pinching&&o>l+h?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=l-h&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==l&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),null!==r&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1));null!==o&&(n=t.getPose(e.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(wn)))}return null!==o&&(o.visible=null!==n),null!==l&&(l.visible=null!==r),null!==c&&(c.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const i=new Group;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class DepthTexture extends Texture$1{constructor(e,t,i,n,r,a,o,l,c,h){if((h=void 0!==h?h:te)!==te&&h!==ie)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===te&&(i=Y),void 0===i&&h===ie&&(i=J),super(null,n,r,a,o,l,h,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==o?o:B,this.minFilter=void 0!==l?l:B,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class WebXRManager extends EventDispatcher{constructor(e,t){super();const i=this;let n=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,A=null,p=null,m=null;const g=t.getContextAttributes();let f=null,v=null;const E=[],y=[],_=new PerspectiveCamera;_.layers.enable(1),_.viewport=new Vector4;const x=new PerspectiveCamera;x.layers.enable(2),x.viewport=new Vector4;const S=[_,x],C=new ArrayCamera;C.layers.enable(1),C.layers.enable(2);let b=null,I=null;function onSessionEvent(e){const t=y.indexOf(e.inputSource);if(-1===t)return;const i=E[t];void 0!==i&&(i.update(e.inputSource,e.frame,c||a),i.dispatchEvent({type:e.type,data:e.inputSource}))}function onSessionEnd(){n.removeEventListener("select",onSessionEvent),n.removeEventListener("selectstart",onSessionEvent),n.removeEventListener("selectend",onSessionEvent),n.removeEventListener("squeeze",onSessionEvent),n.removeEventListener("squeezestart",onSessionEvent),n.removeEventListener("squeezeend",onSessionEvent),n.removeEventListener("end",onSessionEnd),n.removeEventListener("inputsourceschange",onInputSourcesChange);for(let e=0;e<E.length;e++){const t=y[e];null!==t&&(y[e]=null,E[e].disconnect(t))}b=null,I=null,e.setRenderTarget(f),p=null,A=null,d=null,n=null,v=null,F.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function onInputSourcesChange(e){for(let t=0;t<e.removed.length;t++){const i=e.removed[t],n=y.indexOf(i);n>=0&&(y[n]=null,E[n].disconnect(i))}for(let t=0;t<e.added.length;t++){const i=e.added[t];let n=y.indexOf(i);if(-1===n){for(let e=0;e<E.length;e++){if(e>=y.length){y.push(i),n=e;break}if(null===y[e]){y[e]=i,n=e;break}}if(-1===n)break}const r=E[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=E[e];return void 0===t&&(t=new WebXRController,E[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=E[e];return void 0===t&&(t=new WebXRController,E[e]=t),t.getGripSpace()},this.getHand=function(e){let t=E[e];return void 0===t&&(t=new WebXRController,E[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return null!==A?A:p},this.getBinding=function(){return d},this.getFrame=function(){return m},this.getSession=function(){return n},this.setSession=async function(h){if(n=h,null!==n){if(f=e.getRenderTarget(),n.addEventListener("select",onSessionEvent),n.addEventListener("selectstart",onSessionEvent),n.addEventListener("selectend",onSessionEvent),n.addEventListener("squeeze",onSessionEvent),n.addEventListener("squeezestart",onSessionEvent),n.addEventListener("squeezeend",onSessionEvent),n.addEventListener("end",onSessionEnd),n.addEventListener("inputsourceschange",onInputSourcesChange),!0!==g.xrCompatible&&await t.makeXRCompatible(),void 0===n.renderState.layers||!1===e.capabilities.isWebGL2){const i={antialias:void 0!==n.renderState.layers||g.antialias,alpha:!0,depth:g.depth,stencil:g.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(n,t,i),n.updateRenderState({baseLayer:p}),v=new WebGLRenderTarget(p.framebufferWidth,p.framebufferHeight,{format:ee,type:q,colorSpace:e.outputColorSpace,stencilBuffer:g.stencil})}else{let i=null,a=null,o=null;g.depth&&(o=g.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,i=g.stencil?ie:te,a=g.stencil?J:Y);const l={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:r};d=new XRWebGLBinding(n,t),A=d.createProjectionLayer(l),n.updateRenderState({layers:[A]}),v=new WebGLRenderTarget(A.textureWidth,A.textureHeight,{format:ee,type:q,depthTexture:new DepthTexture(A.textureWidth,A.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:g.stencil,colorSpace:e.outputColorSpace,samples:g.antialias?4:0});e.properties.get(v).__ignoreDepthValues=A.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await n.requestReferenceSpace(o),F.setContext(n),F.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode};const T=new Vector3,B=new Vector3;function updateCamera(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===n)return;C.near=x.near=_.near=e.near,C.far=x.far=_.far=e.far,b===C.near&&I===C.far||(n.updateRenderState({depthNear:C.near,depthFar:C.far}),b=C.near,I=C.far);const t=e.parent,i=C.cameras;updateCamera(C,t);for(let e=0;e<i.length;e++)updateCamera(i[e],t);2===i.length?function setProjectionFromUnion(e,t,i){T.setFromMatrixPosition(t.matrixWorld),B.setFromMatrixPosition(i.matrixWorld);const n=T.distanceTo(B),r=t.projectionMatrix.elements,a=i.projectionMatrix.elements,o=r[14]/(r[10]-1),l=r[14]/(r[10]+1),c=(r[9]+1)/r[5],h=(r[9]-1)/r[5],d=(r[8]-1)/r[0],A=(a[8]+1)/a[0],p=o*d,m=o*A,g=n/(-d+A),f=g*-d;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(f),e.translateZ(g),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const v=o+g,E=l+g,y=p-f,_=m+(n-f),x=c*l/E*v,S=h*l/E*v;e.projectionMatrix.makePerspective(y,_,x,S,v,E),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(C,_,x):C.projectionMatrix.copy(_.projectionMatrix),function updateUserCamera(e,t,i){null===i?e.matrix.copy(t.matrixWorld):(e.matrix.copy(i.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0);const n=e.children;for(let e=0,t=n.length;e<t;e++)n[e].updateMatrixWorld(!0);e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*qe*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,C,t)},this.getCamera=function(){return C},this.getFoveation=function(){if(null!==A||null!==p)return l},this.setFoveation=function(e){l=e,null!==A&&(A.fixedFoveation=e),null!==p&&void 0!==p.fixedFoveation&&(p.fixedFoveation=e)};let U=null;const F=new WebGLAnimation;F.setAnimationLoop((function onAnimationFrame(t,n){if(h=n.getViewerPose(c||a),m=n,null!==h){const t=h.views;null!==p&&(e.setRenderTargetFramebuffer(v,p.framebuffer),e.setRenderTarget(v));let i=!1;t.length!==C.cameras.length&&(C.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){const r=t[n];let a=null;if(null!==p)a=p.getViewport(r);else{const t=d.getViewSubImage(A,r);a=t.viewport,0===n&&(e.setRenderTargetTextures(v,t.colorTexture,A.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(v))}let o=S[n];void 0===o&&(o=new PerspectiveCamera,o.layers.enable(n),o.viewport=new Vector4,S[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),0===n&&(C.matrix.copy(o.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),!0===i&&C.cameras.push(o)}}for(let e=0;e<E.length;e++){const t=y[e],i=E[e];null!==t&&void 0!==i&&i.update(t,n,c||a)}U&&U(t,n),n.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:n}),m=null})),this.setAnimationLoop=function(e){U=e},this.dispose=function(){}}}function WebGLMaterials(e,t){function refreshTransformUniform(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function refreshUniformsCommon(i,n){i.opacity.value=n.opacity,n.color&&i.diffuse.value.copy(n.color),n.emissive&&i.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(i.map.value=n.map,refreshTransformUniform(n.map,i.mapTransform)),n.alphaMap&&(i.alphaMap.value=n.alphaMap,refreshTransformUniform(n.alphaMap,i.alphaMapTransform)),n.bumpMap&&(i.bumpMap.value=n.bumpMap,refreshTransformUniform(n.bumpMap,i.bumpMapTransform),i.bumpScale.value=n.bumpScale,1===n.side&&(i.bumpScale.value*=-1)),n.normalMap&&(i.normalMap.value=n.normalMap,refreshTransformUniform(n.normalMap,i.normalMapTransform),i.normalScale.value.copy(n.normalScale),1===n.side&&i.normalScale.value.negate()),n.displacementMap&&(i.displacementMap.value=n.displacementMap,refreshTransformUniform(n.displacementMap,i.displacementMapTransform),i.displacementScale.value=n.displacementScale,i.displacementBias.value=n.displacementBias),n.emissiveMap&&(i.emissiveMap.value=n.emissiveMap,refreshTransformUniform(n.emissiveMap,i.emissiveMapTransform)),n.specularMap&&(i.specularMap.value=n.specularMap,refreshTransformUniform(n.specularMap,i.specularMapTransform)),n.alphaTest>0&&(i.alphaTest.value=n.alphaTest);const r=t.get(n).envMap;if(r&&(i.envMap.value=r,i.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,i.reflectivity.value=n.reflectivity,i.ior.value=n.ior,i.refractionRatio.value=n.refractionRatio),n.lightMap){i.lightMap.value=n.lightMap;const t=!0===e.useLegacyLights?Math.PI:1;i.lightMapIntensity.value=n.lightMapIntensity*t,refreshTransformUniform(n.lightMap,i.lightMapTransform)}n.aoMap&&(i.aoMap.value=n.aoMap,i.aoMapIntensity.value=n.aoMapIntensity,refreshTransformUniform(n.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function refreshFogUniforms(t,i){i.color.getRGB(t.fogColor.value,getUnlitUniformColorSpace(e)),i.isFog?(t.fogNear.value=i.near,t.fogFar.value=i.far):i.isFogExp2&&(t.fogDensity.value=i.density)},refreshMaterialUniforms:function refreshMaterialUniforms(e,i,n,r,a){i.isMeshBasicMaterial||i.isMeshLambertMaterial?refreshUniformsCommon(e,i):i.isMeshToonMaterial?(refreshUniformsCommon(e,i),function refreshUniformsToon(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(refreshUniformsCommon(e,i),function refreshUniformsPhong(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(refreshUniformsCommon(e,i),function refreshUniformsStandard(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,refreshTransformUniform(i.metalnessMap,e.metalnessMapTransform));e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,refreshTransformUniform(i.roughnessMap,e.roughnessMapTransform));const n=t.get(i).envMap;n&&(e.envMapIntensity.value=i.envMapIntensity)}(e,i),i.isMeshPhysicalMaterial&&function refreshUniformsPhysical(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,refreshTransformUniform(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,refreshTransformUniform(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,refreshTransformUniform(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,refreshTransformUniform(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,refreshTransformUniform(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,refreshTransformUniform(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,refreshTransformUniform(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,refreshTransformUniform(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,refreshTransformUniform(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,refreshTransformUniform(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,refreshTransformUniform(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,refreshTransformUniform(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,i,a)):i.isMeshMatcapMaterial?(refreshUniformsCommon(e,i),function refreshUniformsMatcap(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?refreshUniformsCommon(e,i):i.isMeshDistanceMaterial?(refreshUniformsCommon(e,i),function refreshUniformsDistance(e,i){const n=t.get(i).light;e.referencePosition.value.setFromMatrixPosition(n.matrixWorld),e.nearDistance.value=n.shadow.camera.near,e.farDistance.value=n.shadow.camera.far}(e,i)):i.isMeshNormalMaterial?refreshUniformsCommon(e,i):i.isLineBasicMaterial?(!function refreshUniformsLine(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,refreshTransformUniform(t.map,e.mapTransform))}(e,i),i.isLineDashedMaterial&&function refreshUniformsDash(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function refreshUniformsPoints(e,t,i,n){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*n,t.map&&(e.map.value=t.map,refreshTransformUniform(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,refreshTransformUniform(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i,n,r):i.isSpriteMaterial?function refreshUniformsSprites(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,refreshTransformUniform(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,refreshTransformUniform(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function WebGLUniformsGroups(e,t,i,n){let r={},a={},o=[];const l=i.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function hasUniformChanged(e,t,i){const n=e.value;if(void 0===i[t]){if("number"==typeof n)i[t]=n;else{const e=Array.isArray(n)?n:[n],r=[];for(let t=0;t<e.length;t++)r.push(e[t].clone());i[t]=r}return!0}if("number"==typeof n){if(i[t]!==n)return i[t]=n,!0}else{const e=Array.isArray(i[t])?i[t]:[i[t]],r=Array.isArray(n)?n:[n];for(let t=0;t<e.length;t++){const i=e[t];if(!1===i.equals(r[t]))return i.copy(r[t]),!0}}return!1}function getUniformSize(e){const t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function onUniformsGroupsDispose(t){const i=t.target;i.removeEventListener("dispose",onUniformsGroupsDispose);const n=o.indexOf(i.__bindingPointIndex);o.splice(n,1),e.deleteBuffer(r[i.id]),delete r[i.id],delete a[i.id]}return{bind:function bind(e,t){const i=t.program;n.uniformBlockBinding(e,i)},update:function update(i,c){let h=r[i.id];void 0===h&&(!function prepareUniformsGroup(e){const t=e.uniforms;let i=0;const n=16;let r=0;for(let e=0,a=t.length;e<a;e++){const a=t[e],o={boundary:0,storage:0},l=Array.isArray(a.value)?a.value:[a.value];for(let e=0,t=l.length;e<t;e++){const t=getUniformSize(l[e]);o.boundary+=t.boundary,o.storage+=t.storage}if(a.__data=new Float32Array(o.storage/Float32Array.BYTES_PER_ELEMENT),a.__offset=i,e>0){r=i%n;0!==r&&n-r-o.boundary<0&&(i+=n-r,a.__offset=i)}i+=o.storage}r=i%n,r>0&&(i+=n-r);return e.__size=i,e.__cache={},this}(i),h=function createBuffer(t){const i=function allocateBindingPointIndex(){for(let e=0;e<l;e++)if(-1===o.indexOf(e))return o.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=i;const n=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,n),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=h,i.addEventListener("dispose",onUniformsGroupsDispose));const d=c.program;n.updateUBOMapping(i,d);const A=t.render.frame;a[i.id]!==A&&(!function updateBufferData(t){const i=r[t.id],n=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,i);for(let t=0,i=n.length;t<i;t++){const i=n[t];if(!0===hasUniformChanged(i,t,a)){const t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value];let r=0;for(let a=0;a<n.length;a++){const o=n[a],l=getUniformSize(o);"number"==typeof o?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=o.elements[0],i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=o.elements[0],i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=o.elements[0]):(o.toArray(i.__data,r),r+=l.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(i),a[i.id]=A)},dispose:function dispose(){for(const t in r)e.deleteBuffer(r[t]);o=[],r={},a={}}}}function createCanvasElement(){const e=createElementNS("canvas");return e.style.display="block",e}class WebGLRenderer{constructor(e={}){const{canvas:i=createCanvasElement(),context:n=null,depth:r=!0,stencil:a=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:h=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:A=!1}=e;let p;this.isWebGLRenderer=!0,p=null!==n?n.getContextAttributes().alpha:o;const m=new Uint32Array(4),g=new Int32Array(4);let f=null,v=null;const E=[],y=[];this.domElement=i,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=be,this.useLegacyLights=!0,this.toneMapping=0,this.toneMappingExposure=1;const _=this;let x=!1,S=0,C=0,b=null,I=-1,T=null;const B=new Vector4,U=new Vector4;let F=null;const O=new Color(0);let G=0,j=i.width,te=i.height,ie=1,ne=null,re=null;const se=new Vector4(0,0,j,te),ae=new Vector4(0,0,j,te);let oe=!1;const le=new Frustum;let ce=!1,he=!1,ue=null;const de=new Matrix4,Ae=new Vector2,pe=new Vector3,me={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function getTargetPixelRatio(){return null===b?ie:1}let ge,fe,ve,Ee,ye,_e,xe,Se,Ce,Me,we,Te,Be,Re,Le,De,Ue,Pe,Fe,Ne,Qe,Oe,ke,Ge,Ve=n;function getContext(e,t){for(let n=0;n<e.length;n++){const r=e[n],a=i.getContext(r,t);if(null!==a)return a}return null}try{const e={alpha:!0,depth:r,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:h,powerPreference:d,failIfMajorPerformanceCaveat:A};if("setAttribute"in i&&i.setAttribute("data-engine",`three.js r${t}`),i.addEventListener("webglcontextlost",onContextLost,!1),i.addEventListener("webglcontextrestored",onContextRestore,!1),i.addEventListener("webglcontextcreationerror",onContextCreationError,!1),null===Ve){const t=["webgl2","webgl","experimental-webgl"];if(!0===_.isWebGL1Renderer&&t.shift(),Ve=getContext(t,e),null===Ve)throw getContext(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!=typeof WebGLRenderingContext&&Ve instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===Ve.getShaderPrecisionFormat&&(Ve.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function initGLContext(){ge=new WebGLExtensions(Ve),fe=new WebGLCapabilities(Ve,ge,e),ge.init(fe),Oe=new WebGLUtils(Ve,ge,fe),ve=new WebGLState(Ve,ge,fe),Ee=new WebGLInfo(Ve),ye=new WebGLProperties,_e=new WebGLTextures(Ve,ge,ve,ye,fe,Oe,Ee),xe=new WebGLCubeMaps(_),Se=new WebGLCubeUVMaps(_),Ce=new WebGLAttributes(Ve,fe),ke=new WebGLBindingStates(Ve,ge,Ce,fe),Me=new WebGLGeometries(Ve,Ce,Ee,ke),we=new WebGLObjects(Ve,Me,Ce,Ee),Fe=new WebGLMorphtargets(Ve,fe,_e),De=new WebGLClipping(ye),Te=new WebGLPrograms(_,xe,Se,ge,fe,ke,De),Be=new WebGLMaterials(_,ye),Re=new WebGLRenderLists,Le=new WebGLRenderStates(ge,fe),Pe=new WebGLBackground(_,xe,Se,ve,we,p,c),Ue=new WebGLShadowMap(_,we,fe),Ge=new WebGLUniformsGroups(Ve,Ee,fe,ve),Ne=new WebGLBufferRenderer(Ve,ge,Ee,fe),Qe=new WebGLIndexedBufferRenderer(Ve,ge,Ee,fe),Ee.programs=Te.programs,_.capabilities=fe,_.extensions=ge,_.properties=ye,_.renderLists=Re,_.shadowMap=Ue,_.state=ve,_.info=Ee}initGLContext();const He=new WebXRManager(_,Ve);function onContextLost(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function onContextRestore(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const e=Ee.autoReset,t=Ue.enabled,i=Ue.autoUpdate,n=Ue.needsUpdate,r=Ue.type;initGLContext(),Ee.autoReset=e,Ue.enabled=t,Ue.autoUpdate=i,Ue.needsUpdate=n,Ue.type=r}function onContextCreationError(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function onMaterialDispose(e){const t=e.target;t.removeEventListener("dispose",onMaterialDispose),function deallocateMaterial(e){(function releaseMaterialProgramReferences(e){const t=ye.get(e).programs;void 0!==t&&(t.forEach((function(e){Te.releaseProgram(e)})),e.isShaderMaterial&&Te.releaseShaderCache(e))})(e),ye.remove(e)}(t)}this.xr=He,this.getContext=function(){return Ve},this.getContextAttributes=function(){return Ve.getContextAttributes()},this.forceContextLoss=function(){const e=ge.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=ge.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(e){void 0!==e&&(ie=e,this.setSize(j,te,!1))},this.getSize=function(e){return e.set(j,te)},this.setSize=function(e,t,n=!0){He.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(j=e,te=t,i.width=Math.floor(e*ie),i.height=Math.floor(t*ie),!0===n&&(i.style.width=e+"px",i.style.height=t+"px"),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(j*ie,te*ie).floor()},this.setDrawingBufferSize=function(e,t,n){j=e,te=t,ie=n,i.width=Math.floor(e*n),i.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(B)},this.getViewport=function(e){return e.copy(se)},this.setViewport=function(e,t,i,n){e.isVector4?se.set(e.x,e.y,e.z,e.w):se.set(e,t,i,n),ve.viewport(B.copy(se).multiplyScalar(ie).floor())},this.getScissor=function(e){return e.copy(ae)},this.setScissor=function(e,t,i,n){e.isVector4?ae.set(e.x,e.y,e.z,e.w):ae.set(e,t,i,n),ve.scissor(U.copy(ae).multiplyScalar(ie).floor())},this.getScissorTest=function(){return oe},this.setScissorTest=function(e){ve.setScissorTest(oe=e)},this.setOpaqueSort=function(e){ne=e},this.setTransparentSort=function(e){re=e},this.getClearColor=function(e){return e.copy(Pe.getClearColor())},this.setClearColor=function(){Pe.setClearColor.apply(Pe,arguments)},this.getClearAlpha=function(){return Pe.getClearAlpha()},this.setClearAlpha=function(){Pe.setClearAlpha.apply(Pe,arguments)},this.clear=function(e=!0,t=!0,i=!0){let n=0;if(e){let e=!1;if(null!==b){const t=b.texture.format;e=1033===t||1031===t||1029===t}if(e){const e=b.texture.type,t=e===q||e===Y||e===X||e===J||1017===e||1018===e,i=Pe.getClearColor(),n=Pe.getClearAlpha(),r=i.r,a=i.g,o=i.b;t?(m[0]=r,m[1]=a,m[2]=o,m[3]=n,Ve.clearBufferuiv(Ve.COLOR,0,m)):(g[0]=r,g[1]=a,g[2]=o,g[3]=n,Ve.clearBufferiv(Ve.COLOR,0,g))}else n|=Ve.COLOR_BUFFER_BIT}t&&(n|=Ve.DEPTH_BUFFER_BIT),i&&(n|=Ve.STENCIL_BUFFER_BIT),Ve.clear(n)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){i.removeEventListener("webglcontextlost",onContextLost,!1),i.removeEventListener("webglcontextrestored",onContextRestore,!1),i.removeEventListener("webglcontextcreationerror",onContextCreationError,!1),Re.dispose(),Le.dispose(),ye.dispose(),xe.dispose(),Se.dispose(),we.dispose(),ke.dispose(),Ge.dispose(),Te.dispose(),He.dispose(),He.removeEventListener("sessionstart",onXRSessionStart),He.removeEventListener("sessionend",onXRSessionEnd),ue&&(ue.dispose(),ue=null),We.stop()},this.renderBufferDirect=function(e,t,i,n,r,a){null===t&&(t=me);const o=r.isMesh&&r.matrixWorld.determinant()<0,l=function setProgram(e,t,i,n,r){!0!==t.isScene&&(t=me);_e.resetTextureUnits();const a=t.fog,o=n.isMeshStandardMaterial?t.environment:null,l=null===b?_.outputColorSpace:!0===b.isXRRenderTarget?b.texture.colorSpace:Ie,c=(n.isMeshStandardMaterial?Se:xe).get(n.envMap||o),h=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,d=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),A=!!i.morphAttributes.position,p=!!i.morphAttributes.normal,m=!!i.morphAttributes.color,g=n.toneMapped?_.toneMapping:0,f=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,E=void 0!==f?f.length:0,y=ye.get(n),x=v.state.lights;if(!0===ce&&(!0===he||e!==T)){const t=e===T&&n.id===I;De.setState(n,e,t)}let S=!1;n.version===y.__version?y.needsLights&&y.lightsStateVersion!==x.state.version||y.outputColorSpace!==l||r.isInstancedMesh&&!1===y.instancing?S=!0:r.isInstancedMesh||!0!==y.instancing?r.isSkinnedMesh&&!1===y.skinning?S=!0:r.isSkinnedMesh||!0!==y.skinning?y.envMap!==c||!0===n.fog&&y.fog!==a?S=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===De.numPlanes&&y.numIntersection===De.numIntersection?(y.vertexAlphas!==h||y.vertexTangents!==d||y.morphTargets!==A||y.morphNormals!==p||y.morphColors!==m||y.toneMapping!==g||!0===fe.isWebGL2&&y.morphTargetsCount!==E)&&(S=!0):S=!0:S=!0:S=!0:(S=!0,y.__version=n.version);let C=y.currentProgram;!0===S&&(C=getProgram(n,t,r));let B=!1,U=!1,F=!1;const O=C.getUniforms(),G=y.uniforms;ve.useProgram(C.program)&&(B=!0,U=!0,F=!0);n.id!==I&&(I=n.id,U=!0);if(B||T!==e){if(O.setValue(Ve,"projectionMatrix",e.projectionMatrix),fe.logarithmicDepthBuffer&&O.setValue(Ve,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),T!==e&&(T=e,U=!0,F=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){const t=O.map.cameraPosition;void 0!==t&&t.setValue(Ve,pe.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&O.setValue(Ve,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&O.setValue(Ve,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){O.setOptional(Ve,r,"bindMatrix"),O.setOptional(Ve,r,"bindMatrixInverse");const e=r.skeleton;e&&(fe.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),O.setValue(Ve,"boneTexture",e.boneTexture,_e),O.setValue(Ve,"boneTextureSize",e.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 W=i.morphAttributes;(void 0!==W.position||void 0!==W.normal||void 0!==W.color&&!0===fe.isWebGL2)&&Fe.update(r,i,C);(U||y.receiveShadow!==r.receiveShadow)&&(y.receiveShadow=r.receiveShadow,O.setValue(Ve,"receiveShadow",r.receiveShadow));n.isMeshGouraudMaterial&&null!==n.envMap&&(G.envMap.value=c,G.flipEnvMap.value=c.isCubeTexture&&!1===c.isRenderTargetTexture?-1:1);U&&(O.setValue(Ve,"toneMappingExposure",_.toneMappingExposure),y.needsLights&&function markUniformsLightsNeedsUpdate(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(G,F),a&&!0===n.fog&&Be.refreshFogUniforms(G,a),Be.refreshMaterialUniforms(G,n,ie,te,ue),WebGLUniforms.upload(Ve,y.uniformsList,G,_e));n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(WebGLUniforms.upload(Ve,y.uniformsList,G,_e),n.uniformsNeedUpdate=!1);n.isSpriteMaterial&&O.setValue(Ve,"center",r.center);if(O.setValue(Ve,"modelViewMatrix",r.modelViewMatrix),O.setValue(Ve,"normalMatrix",r.normalMatrix),O.setValue(Ve,"modelMatrix",r.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){const e=n.uniformsGroups;for(let t=0,i=e.length;t<i;t++)if(fe.isWebGL2){const i=e[t];Ge.update(i,C),Ge.bind(i,C)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return C}(e,t,i,n,r);ve.setMaterial(n,o);let c=i.index,h=1;!0===n.wireframe&&(c=Me.getWireframeAttribute(i),h=2);const d=i.drawRange,A=i.attributes.position;let p=d.start*h,m=(d.start+d.count)*h;null!==a&&(p=Math.max(p,a.start*h),m=Math.min(m,(a.start+a.count)*h)),null!==c?(p=Math.max(p,0),m=Math.min(m,c.count)):null!=A&&(p=Math.max(p,0),m=Math.min(m,A.count));const g=m-p;if(g<0||g===1/0)return;let f;ke.setup(r,n,l,i,c);let E=Ne;if(null!==c&&(f=Ce.get(c),E=Qe,E.setIndex(f)),r.isMesh)!0===n.wireframe?(ve.setLineWidth(n.wireframeLinewidth*getTargetPixelRatio()),E.setMode(Ve.LINES)):E.setMode(Ve.TRIANGLES);else if(r.isLine){let e=n.linewidth;void 0===e&&(e=1),ve.setLineWidth(e*getTargetPixelRatio()),r.isLineSegments?E.setMode(Ve.LINES):r.isLineLoop?E.setMode(Ve.LINE_LOOP):E.setMode(Ve.LINE_STRIP)}else r.isPoints?E.setMode(Ve.POINTS):r.isSprite&&E.setMode(Ve.TRIANGLES);if(r.isInstancedMesh)E.renderInstances(p,g,r.count);else if(i.isInstancedBufferGeometry){const e=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,t=Math.min(i.instanceCount,e);E.renderInstances(p,g,t)}else E.render(p,g)},this.compile=function(e,t){function prepare(e,t,i){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,getProgram(e,t,i),e.side=0,e.needsUpdate=!0,getProgram(e,t,i),e.side=2):getProgram(e,t,i)}v=Le.get(e),v.init(),y.push(v),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(v.pushLight(e),e.castShadow&&v.pushShadow(e))})),v.setupLights(_.useLegacyLights),e.traverse((function(t){const i=t.material;if(i)if(Array.isArray(i))for(let n=0;n<i.length;n++){prepare(i[n],e,t)}else prepare(i,e,t)})),y.pop(),v=null};let ze=null;function onXRSessionStart(){We.stop()}function onXRSessionEnd(){We.start()}const We=new WebGLAnimation;function projectObject(e,t,i,n){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)i=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)v.pushLight(e),e.castShadow&&v.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||le.intersectsSprite(e)){n&&pe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(de);const t=we.update(e),r=e.material;r.visible&&f.push(e,t,r,i,pe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||le.intersectsObject(e))){const t=we.update(e),r=e.material;if(n&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),pe.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),pe.copy(t.boundingSphere.center)),pe.applyMatrix4(e.matrixWorld).applyMatrix4(de)),Array.isArray(r)){const n=t.groups;for(let a=0,o=n.length;a<o;a++){const o=n[a],l=r[o.materialIndex];l&&l.visible&&f.push(e,t,l,i,pe.z,o)}}else r.visible&&f.push(e,t,r,i,pe.z,null)}const r=e.children;for(let e=0,a=r.length;e<a;e++)projectObject(r[e],t,i,n)}function renderScene(e,t,i,n){const r=e.opaque,a=e.transmissive,o=e.transparent;v.setupLightsView(i),!0===ce&&De.setGlobalState(_.clippingPlanes,i),a.length>0&&function renderTransmissionPass(e,t,i,n){const r=fe.isWebGL2;null===ue&&(ue=new WebGLRenderTarget(1,1,{generateMipmaps:!0,type:ge.has("EXT_color_buffer_half_float")?$:q,minFilter:W,samples:r?4:0}));_.getDrawingBufferSize(Ae),r?ue.setSize(Ae.x,Ae.y):ue.setSize(floorPowerOfTwo(Ae.x),floorPowerOfTwo(Ae.y));const a=_.getRenderTarget();_.setRenderTarget(ue),_.getClearColor(O),G=_.getClearAlpha(),G<1&&_.setClearColor(16777215,.5);_.clear();const o=_.toneMapping;_.toneMapping=0,renderObjects(e,i,n),_e.updateMultisampleRenderTarget(ue),_e.updateRenderTargetMipmap(ue);let l=!1;for(let e=0,r=t.length;e<r;e++){const r=t[e],a=r.object,o=r.geometry,c=r.material,h=r.group;if(2===c.side&&a.layers.test(n.layers)){const e=c.side;c.side=1,c.needsUpdate=!0,renderObject(a,i,n,o,c,h),c.side=e,c.needsUpdate=!0,l=!0}}!0===l&&(_e.updateMultisampleRenderTarget(ue),_e.updateRenderTargetMipmap(ue));_.setRenderTarget(a),_.setClearColor(O,G),_.toneMapping=o}(r,a,t,i),n&&ve.viewport(B.copy(n)),r.length>0&&renderObjects(r,t,i),a.length>0&&renderObjects(a,t,i),o.length>0&&renderObjects(o,t,i),ve.buffers.depth.setTest(!0),ve.buffers.depth.setMask(!0),ve.buffers.color.setMask(!0),ve.setPolygonOffset(!1)}function renderObjects(e,t,i){const n=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r<a;r++){const a=e[r],o=a.object,l=a.geometry,c=null===n?a.material:n,h=a.group;o.layers.test(i.layers)&&renderObject(o,t,i,l,c,h)}}function renderObject(e,t,i,n,r,a){e.onBeforeRender(_,t,i,n,r,a),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(_,t,i,n,e,a),!0===r.transparent&&2===r.side&&!1===r.forceSinglePass?(r.side=1,r.needsUpdate=!0,_.renderBufferDirect(i,t,n,r,e,a),r.side=0,r.needsUpdate=!0,_.renderBufferDirect(i,t,n,r,e,a),r.side=2):_.renderBufferDirect(i,t,n,r,e,a),e.onAfterRender(_,t,i,n,r,a)}function getProgram(e,t,i){!0!==t.isScene&&(t=me);const n=ye.get(e),r=v.state.lights,a=v.state.shadowsArray,o=r.state.version,l=Te.getParameters(e,r.state,a,t,i),c=Te.getProgramCacheKey(l);let h=n.programs;n.environment=e.isMeshStandardMaterial?t.environment:null,n.fog=t.fog,n.envMap=(e.isMeshStandardMaterial?Se:xe).get(e.envMap||n.environment),void 0===h&&(e.addEventListener("dispose",onMaterialDispose),h=new Map,n.programs=h);let d=h.get(c);if(void 0!==d){if(n.currentProgram===d&&n.lightsStateVersion===o)return updateCommonMaterialProperties(e,l),d}else l.uniforms=Te.getUniforms(e),e.onBuild(i,l,_),e.onBeforeCompile(l,_),d=Te.acquireProgram(l,c),h.set(c,d),n.uniforms=l.uniforms;const A=n.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(A.clippingPlanes=De.uniform),updateCommonMaterialProperties(e,l),n.needsLights=function materialNeedsLights(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),n.lightsStateVersion=o,n.needsLights&&(A.ambientLightColor.value=r.state.ambient,A.lightProbe.value=r.state.probe,A.directionalLights.value=r.state.directional,A.directionalLightShadows.value=r.state.directionalShadow,A.spotLights.value=r.state.spot,A.spotLightShadows.value=r.state.spotShadow,A.rectAreaLights.value=r.state.rectArea,A.ltc_1.value=r.state.rectAreaLTC1,A.ltc_2.value=r.state.rectAreaLTC2,A.pointLights.value=r.state.point,A.pointLightShadows.value=r.state.pointShadow,A.hemisphereLights.value=r.state.hemi,A.directionalShadowMap.value=r.state.directionalShadowMap,A.directionalShadowMatrix.value=r.state.directionalShadowMatrix,A.spotShadowMap.value=r.state.spotShadowMap,A.spotLightMatrix.value=r.state.spotLightMatrix,A.spotLightMap.value=r.state.spotLightMap,A.pointShadowMap.value=r.state.pointShadowMap,A.pointShadowMatrix.value=r.state.pointShadowMatrix);const p=d.getUniforms(),m=WebGLUniforms.seqWithValue(p.seq,A);return n.currentProgram=d,n.uniformsList=m,d}function updateCommonMaterialProperties(e,t){const i=ye.get(e);i.outputColorSpace=t.outputColorSpace,i.instancing=t.instancing,i.skinning=t.skinning,i.morphTargets=t.morphTargets,i.morphNormals=t.morphNormals,i.morphColors=t.morphColors,i.morphTargetsCount=t.morphTargetsCount,i.numClippingPlanes=t.numClippingPlanes,i.numIntersection=t.numClipIntersection,i.vertexAlphas=t.vertexAlphas,i.vertexTangents=t.vertexTangents,i.toneMapping=t.toneMapping}We.setAnimationLoop((function onAnimationFrame(e){ze&&ze(e)})),"undefined"!=typeof self&&We.setContext(self),this.setAnimationLoop=function(e){ze=e,He.setAnimationLoop(e),null===e?We.stop():We.start()},He.addEventListener("sessionstart",onXRSessionStart),He.addEventListener("sessionend",onXRSessionEnd),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===x)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===He.enabled&&!0===He.isPresenting&&(!0===He.cameraAutoUpdate&&He.updateCamera(t),t=He.getCamera()),!0===e.isScene&&e.onBeforeRender(_,e,t,b),v=Le.get(e,y.length),v.init(),y.push(v),de.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),le.setFromProjectionMatrix(de),he=this.localClippingEnabled,ce=De.init(this.clippingPlanes,he),f=Re.get(e,E.length),f.init(),E.push(f),projectObject(e,t,0,_.sortObjects),f.finish(),!0===_.sortObjects&&f.sort(ne,re),this.info.render.frame++,!0===ce&&De.beginShadows();const i=v.state.shadowsArray;if(Ue.render(i,e,t),!0===ce&&De.endShadows(),!0===this.info.autoReset&&this.info.reset(),Pe.render(f,e),v.setupLights(_.useLegacyLights),t.isArrayCamera){const i=t.cameras;for(let t=0,n=i.length;t<n;t++){const n=i[t];renderScene(f,e,n,n.viewport)}}else renderScene(f,e,t);null!==b&&(_e.updateMultisampleRenderTarget(b),_e.updateRenderTargetMipmap(b)),!0===e.isScene&&e.onAfterRender(_,e,t),ke.resetDefaultState(),I=-1,T=null,y.pop(),v=y.length>0?y[y.length-1]:null,E.pop(),f=E.length>0?E[E.length-1]:null},this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(e,t,i){ye.get(e.texture).__webglTexture=t,ye.get(e.depthTexture).__webglTexture=i;const n=ye.get(e);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===ge.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(e,t){const i=ye.get(e);i.__webglFramebuffer=t,i.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,i=0){b=e,S=t,C=i;let n=!0,r=null,a=!1,o=!1;if(e){const i=ye.get(e);void 0!==i.__useDefaultFramebuffer?(ve.bindFramebuffer(Ve.FRAMEBUFFER,null),n=!1):void 0===i.__webglFramebuffer?_e.setupRenderTarget(e):i.__hasExternalTextures&&_e.rebindTextures(e,ye.get(e.texture).__webglTexture,ye.get(e.depthTexture).__webglTexture);const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(o=!0);const c=ye.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=c[t],a=!0):r=fe.isWebGL2&&e.samples>0&&!1===_e.useMultisampledRTT(e)?ye.get(e).__webglMultisampledFramebuffer:c,B.copy(e.viewport),U.copy(e.scissor),F=e.scissorTest}else B.copy(se).multiplyScalar(ie).floor(),U.copy(ae).multiplyScalar(ie).floor(),F=oe;if(ve.bindFramebuffer(Ve.FRAMEBUFFER,r)&&fe.drawBuffers&&n&&ve.drawBuffers(e,r),ve.viewport(B),ve.scissor(U),ve.setScissorTest(F),a){const n=ye.get(e.texture);Ve.framebufferTexture2D(Ve.FRAMEBUFFER,Ve.COLOR_ATTACHMENT0,Ve.TEXTURE_CUBE_MAP_POSITIVE_X+t,n.__webglTexture,i)}else if(o){const n=ye.get(e.texture),r=t||0;Ve.framebufferTextureLayer(Ve.FRAMEBUFFER,Ve.COLOR_ATTACHMENT0,n.__webglTexture,i||0,r)}I=-1},this.readRenderTargetPixels=function(e,t,i,n,r,a,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=ye.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(l=l[o]),l){ve.bindFramebuffer(Ve.FRAMEBUFFER,l);try{const o=e.texture,l=o.format,c=o.type;if(l!==ee&&Oe.convert(l)!==Ve.getParameter(Ve.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const h=c===$&&(ge.has("EXT_color_buffer_half_float")||fe.isWebGL2&&ge.has("EXT_color_buffer_float"));if(!(c===q||Oe.convert(c)===Ve.getParameter(Ve.IMPLEMENTATION_COLOR_READ_TYPE)||c===K&&(fe.isWebGL2||ge.has("OES_texture_float")||ge.has("WEBGL_color_buffer_float"))||h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-n&&i>=0&&i<=e.height-r&&Ve.readPixels(t,i,n,r,Oe.convert(l),Oe.convert(c),a)}finally{const e=null!==b?ye.get(b).__webglFramebuffer:null;ve.bindFramebuffer(Ve.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,i=0){const n=Math.pow(2,-i),r=Math.floor(t.image.width*n),a=Math.floor(t.image.height*n);_e.setTexture2D(t,0),Ve.copyTexSubImage2D(Ve.TEXTURE_2D,i,0,0,e.x,e.y,r,a),ve.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n=0){const r=t.image.width,a=t.image.height,o=Oe.convert(i.format),l=Oe.convert(i.type);_e.setTexture2D(i,0),Ve.pixelStorei(Ve.UNPACK_FLIP_Y_WEBGL,i.flipY),Ve.pixelStorei(Ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Ve.pixelStorei(Ve.UNPACK_ALIGNMENT,i.unpackAlignment),t.isDataTexture?Ve.texSubImage2D(Ve.TEXTURE_2D,n,e.x,e.y,r,a,o,l,t.image.data):t.isCompressedTexture?Ve.compressedTexSubImage2D(Ve.TEXTURE_2D,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):Ve.texSubImage2D(Ve.TEXTURE_2D,n,e.x,e.y,o,l,t.image),0===n&&i.generateMipmaps&&Ve.generateMipmap(Ve.TEXTURE_2D),ve.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,n,r=0){if(_.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,l=e.max.z-e.min.z+1,c=Oe.convert(n.format),h=Oe.convert(n.type);let d;if(n.isData3DTexture)_e.setTexture3D(n,0),d=Ve.TEXTURE_3D;else{if(!n.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");_e.setTexture2DArray(n,0),d=Ve.TEXTURE_2D_ARRAY}Ve.pixelStorei(Ve.UNPACK_FLIP_Y_WEBGL,n.flipY),Ve.pixelStorei(Ve.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Ve.pixelStorei(Ve.UNPACK_ALIGNMENT,n.unpackAlignment);const A=Ve.getParameter(Ve.UNPACK_ROW_LENGTH),p=Ve.getParameter(Ve.UNPACK_IMAGE_HEIGHT),m=Ve.getParameter(Ve.UNPACK_SKIP_PIXELS),g=Ve.getParameter(Ve.UNPACK_SKIP_ROWS),f=Ve.getParameter(Ve.UNPACK_SKIP_IMAGES),v=i.isCompressedTexture?i.mipmaps[0]:i.image;Ve.pixelStorei(Ve.UNPACK_ROW_LENGTH,v.width),Ve.pixelStorei(Ve.UNPACK_IMAGE_HEIGHT,v.height),Ve.pixelStorei(Ve.UNPACK_SKIP_PIXELS,e.min.x),Ve.pixelStorei(Ve.UNPACK_SKIP_ROWS,e.min.y),Ve.pixelStorei(Ve.UNPACK_SKIP_IMAGES,e.min.z),i.isDataTexture||i.isData3DTexture?Ve.texSubImage3D(d,r,t.x,t.y,t.z,a,o,l,c,h,v.data):i.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Ve.compressedTexSubImage3D(d,r,t.x,t.y,t.z,a,o,l,c,v.data)):Ve.texSubImage3D(d,r,t.x,t.y,t.z,a,o,l,c,h,v),Ve.pixelStorei(Ve.UNPACK_ROW_LENGTH,A),Ve.pixelStorei(Ve.UNPACK_IMAGE_HEIGHT,p),Ve.pixelStorei(Ve.UNPACK_SKIP_PIXELS,m),Ve.pixelStorei(Ve.UNPACK_SKIP_ROWS,g),Ve.pixelStorei(Ve.UNPACK_SKIP_IMAGES,f),0===r&&n.generateMipmaps&&Ve.generateMipmap(d),ve.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?_e.setTextureCube(e,0):e.isData3DTexture?_e.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?_e.setTexture2DArray(e,0):_e.setTexture2D(e,0),ve.unbindTexture()},this.resetState=function(){S=0,C=0,b=null,ve.reset(),ke.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ge}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===be?Ce:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ce?be:Ie}}(class WebGL1Renderer extends WebGLRenderer{}).prototype.isWebGL1Renderer=!0;class Scene extends Object3D{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(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class InterleavedBuffer{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Qe,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=generateUUID()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Tn=new Vector3;class InterleavedBufferAttribute{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)Tn.fromBufferAttribute(this,t),Tn.applyMatrix4(e),this.setXYZ(t,Tn.x,Tn.y,Tn.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Tn.fromBufferAttribute(this,t),Tn.applyNormalMatrix(e),this.setXYZ(t,Tn.x,Tn.y,Tn.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Tn.fromBufferAttribute(this,t),Tn.transformDirection(e),this.setXYZ(t,Tn.x,Tn.y,Tn.z);return this}setX(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=normalize(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=denormalize(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=denormalize(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=denormalize(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=denormalize(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),i=normalize(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),i=normalize(i,this.array),n=normalize(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=normalize(t,this.array),i=normalize(i,this.array),n=normalize(n,this.array),r=normalize(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this.data.array[e+3]=r,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return new BufferAttribute(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new InterleavedBufferAttribute(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const Bn=new Vector3,Rn=new Vector4,Ln=new Vector4,Dn=new Vector3,Un=new Matrix4,Pn=new Vector3,Fn=new Sphere,Nn=new Matrix4,Qn=new Ray;class SkinnedMesh extends Mesh{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Matrix4,this.bindMatrixInverse=new Matrix4,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;null===this.boundingBox&&(this.boundingBox=new Box3),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)Pn.fromBufferAttribute(t,e),this.applyBoneTransform(e,Pn),this.boundingBox.expandByPoint(Pn)}computeBoundingSphere(){const e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Sphere),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let e=0;e<t.count;e++)Pn.fromBufferAttribute(t,e),this.applyBoneTransform(e,Pn),this.boundingSphere.expandByPoint(Pn)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const i=this.material,n=this.matrixWorld;void 0!==i&&(null===this.boundingSphere&&this.computeBoundingSphere(),Fn.copy(this.boundingSphere),Fn.applyMatrix4(n),!1!==e.ray.intersectsSphere(Fn)&&(Nn.copy(n).invert(),Qn.copy(e.ray).applyMatrix4(Nn),null!==this.boundingBox&&!1===Qn.intersectsBox(this.boundingBox)||this._computeIntersections(e,t,Qn)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Vector4,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);const n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,n=this.geometry;Rn.fromBufferAttribute(n.attributes.skinIndex,e),Ln.fromBufferAttribute(n.attributes.skinWeight,e),Bn.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const n=Ln.getComponent(e);if(0!==n){const r=Rn.getComponent(e);Un.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),t.addScaledVector(Dn.copy(Bn).applyMatrix4(Un),n)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class Bone extends Object3D{constructor(){super(),this.isBone=!0,this.type="Bone"}}class DataTexture extends Texture$1{constructor(e=null,t=1,i=1,n,r,a,o,l,c=1003,h=1003,d,A){super(null,a,o,l,c,h,n,r,d,A),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const On=new Matrix4,kn=new Matrix4;class Skeleton{constructor(e=[],t=[]){this.uuid=generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new Matrix4)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new Matrix4;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let n=0,r=e.length;n<r;n++){const r=e[n]?e[n].matrixWorld:kn;On.multiplyMatrices(r,t[n]),On.toArray(i,16*n)}null!==n&&(n.needsUpdate=!0)}clone(){return new Skeleton(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=ceilPowerOfTwo(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new DataTexture(t,e,e,ee,K);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){const n=e.bones[i];let r=t[n];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new Bone),this.bones.push(r),this.boneInverses.push((new Matrix4).fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){const r=t[n];e.bones.push(r.uuid);const a=i[n];e.boneInverses.push(a.toArray())}return e}}class InstancedBufferAttribute extends BufferAttribute{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Gn=new Matrix4,Vn=new Matrix4,Hn=[],zn=new Box3,Wn=new Matrix4,qn=new Mesh,Xn=new Sphere;class InstancedMesh extends Mesh{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new InstancedBufferAttribute(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<i;e++)this.setMatrixAt(e,Wn)}computeBoundingBox(){const e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Box3),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Gn),zn.copy(e.boundingBox).applyMatrix4(Gn),this.boundingBox.union(zn)}computeBoundingSphere(){const e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new Sphere),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,Gn),Xn.copy(e.boundingSphere).applyMatrix4(Gn),this.boundingSphere.union(Xn)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const i=this.matrixWorld,n=this.count;if(qn.geometry=this.geometry,qn.material=this.material,void 0!==qn.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Xn.copy(this.boundingSphere),Xn.applyMatrix4(i),!1!==e.ray.intersectsSphere(Xn)))for(let r=0;r<n;r++){this.getMatrixAt(r,Gn),Vn.multiplyMatrices(i,Gn),qn.matrixWorld=Vn,qn.raycast(e,Hn);for(let e=0,i=Hn.length;e<i;e++){const i=Hn[e];i.instanceId=r,i.object=this,t.push(i)}Hn.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new InstancedBufferAttribute(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class LineBasicMaterial extends Material$1{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Color(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const jn=new Vector3,Yn=new Vector3,Kn=new Matrix4,$n=new Ray,Jn=new Sphere;class Line extends Object3D{constructor(e=new BufferGeometry,t=new LineBasicMaterial){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,i=[0];for(let e=1,n=t.count;e<n;e++)jn.fromBufferAttribute(t,e-1),Yn.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=jn.distanceTo(Yn);e.setAttribute("lineDistance",new Float32BufferAttribute(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Jn.copy(i.boundingSphere),Jn.applyMatrix4(n),Jn.radius+=r,!1===e.ray.intersectsSphere(Jn))return;Kn.copy(n).invert(),$n.copy(e.ray).applyMatrix4(Kn);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=new Vector3,h=new Vector3,d=new Vector3,A=new Vector3,p=this.isLineSegments?2:1,m=i.index,g=i.attributes.position;if(null!==m){for(let i=Math.max(0,a.start),n=Math.min(m.count,a.start+a.count)-1;i<n;i+=p){const n=m.getX(i),r=m.getX(i+1);c.fromBufferAttribute(g,n),h.fromBufferAttribute(g,r);if($n.distanceSqToSegment(c,h,A,d)>l)continue;A.applyMatrix4(this.matrixWorld);const a=e.ray.origin.distanceTo(A);a<e.near||a>e.far||t.push({distance:a,point:d.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{for(let i=Math.max(0,a.start),n=Math.min(g.count,a.start+a.count)-1;i<n;i+=p){c.fromBufferAttribute(g,i),h.fromBufferAttribute(g,i+1);if($n.distanceSqToSegment(c,h,A,d)>l)continue;A.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(A);n<e.near||n>e.far||t.push({distance:n,point:d.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){const t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const Zn=new Vector3,er=new Vector3;class LineSegments extends Line{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,i=[];for(let e=0,n=t.count;e<n;e+=2)Zn.fromBufferAttribute(t,e),er.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+Zn.distanceTo(er);e.setAttribute("lineDistance",new Float32BufferAttribute(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class LineLoop extends Line{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class PointsMaterial extends Material$1{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Color(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const tr=new Matrix4,ir=new Ray,nr=new Sphere,rr=new Vector3;class Points extends Object3D{constructor(e=new BufferGeometry,t=new PointsMaterial){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),nr.copy(i.boundingSphere),nr.applyMatrix4(n),nr.radius+=r,!1===e.ray.intersectsSphere(nr))return;tr.copy(n).invert(),ir.copy(e.ray).applyMatrix4(tr);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,h=i.attributes.position;if(null!==c){for(let i=Math.max(0,a.start),r=Math.min(c.count,a.start+a.count);i<r;i++){const r=c.getX(i);rr.fromBufferAttribute(h,r),testPoint(rr,r,l,n,e,t,this)}}else{for(let i=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count);i<r;i++)rr.fromBufferAttribute(h,i),testPoint(rr,i,l,n,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){const t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function testPoint(e,t,i,n,r,a,o){const l=ir.distanceSqToPoint(e);if(l<i){const i=new Vector3;ir.closestPointToPoint(e,i),i.applyMatrix4(n);const c=r.ray.origin.distanceTo(i);if(c<r.near||c>r.far)return;a.push({distance:c,distanceToRay:Math.sqrt(l),point:i,index:t,face:null,object:o})}}class VideoTexture extends Texture$1{constructor(e,t,i,n,r,a,o,l,c){super(e,t,i,n,r,a,o,l,c),this.isVideoTexture=!0,this.minFilter=void 0!==a?a:O,this.magFilter=void 0!==r?r:O,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function updateVideo(){h.needsUpdate=!0,e.requestVideoFrameCallback(updateVideo)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class CompressedTexture extends Texture$1{constructor(e,t,i,n,r,a,o,l,c,h,d,A){super(null,a,o,l,c,h,n,r,d,A),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class CompressedArrayTexture extends CompressedTexture{constructor(e,t,i,n,r,a){super(e,t,i,r,a),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=I}}class CanvasTexture extends Texture$1{constructor(e,t,i,n,r,a,o,l,c){super(e,t,i,n,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class MeshStandardMaterial extends Material$1{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Color(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 Color(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Vector2(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(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class MeshPhysicalMaterial extends MeshStandardMaterial{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Vector2(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return clamp$1(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Color(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 Color(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Color(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}function arraySlice(e,t,i){return isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)}function convertArray(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function getKeyframeOrder(e){const t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort((function compareTime(t,i){return e[t]-e[i]})),i}function sortedArray(e,t,i){const n=e.length,r=new e.constructor(n);for(let a=0,o=0;o!==n;++a){const n=i[a]*t;for(let i=0;i!==t;++i)r[o++]=e[n+i]}return r}function flattenJSON(e,t,i,n){let r=1,a=e[0];for(;void 0!==a&&void 0===a[n];)a=e[r++];if(void 0===a)return;let o=a[n];if(void 0!==o)if(Array.isArray(o))do{o=a[n],void 0!==o&&(t.push(a.time),i.push.apply(i,o)),a=e[r++]}while(void 0!==a);else if(void 0!==o.toArray)do{o=a[n],void 0!==o&&(t.push(a.time),o.toArray(i,i.length)),a=e[r++]}while(void 0!==a);else do{o=a[n],void 0!==o&&(t.push(a.time),i.push(o)),a=e[r++]}while(void 0!==a)}class Interpolant{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let a;i:{n:if(!(e<n)){for(let a=i+2;;){if(void 0===n){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(r=n,n=t[++i],e<n)break t}a=t.length;break i}if(e>=r)break e;{const o=t[1];e<o&&(i=2,r=o);for(let a=i-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(i===a)break;if(n=r,r=t[--i-1],e>=r)break t}a=i,i=0}}for(;i<a;){const n=i+a>>>1;e<t[n]?a=n:i=n+1}if(n=t[i],r=t[i-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===n)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let e=0;e!==n;++e)t[e]=i[r+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class CubicInterpolant extends Interpolant{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ye,endingEnd:ye}}intervalChanged_(e,t,i){const n=this.parameterPositions;let r=e-2,a=e+1,o=n[r],l=n[a];if(void 0===o)switch(this.getSettings_().endingStart){case _e:r=e,o=2*t-i;break;case xe:r=n.length-2,o=t+n[r]-n[r+1];break;default:r=e,o=i}if(void 0===l)switch(this.getSettings_().endingEnd){case _e:a=e,l=2*i-t;break;case xe:a=1,l=i+n[1]-n[0];break;default:a=e-1,l=t}const c=.5*(i-t),h=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-i),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=this._offsetPrev,d=this._offsetNext,A=this._weightPrev,p=this._weightNext,m=(i-t)/(n-t),g=m*m,f=g*m,v=-A*f+2*A*g-A*m,E=(1+A)*f+(-1.5-2*A)*g+(-.5+A)*m+1,y=(-1-p)*f+(1.5+p)*g+.5*m,_=p*f-p*g;for(let e=0;e!==o;++e)r[e]=v*a[h+e]+E*a[c+e]+y*a[l+e]+_*a[d+e];return r}}class LinearInterpolant extends Interpolant{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,h=(i-t)/(n-t),d=1-h;for(let e=0;e!==o;++e)r[e]=a[c+e]*d+a[l+e]*h;return r}}class DiscreteInterpolant extends Interpolant{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}}class KeyframeTrack{constructor(e,t,i,n){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=convertArray(t,this.TimeBufferType),this.values=convertArray(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:convertArray(e.times,Array),values:convertArray(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(i.interpolation=t)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new DiscreteInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new LinearInterpolant(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new CubicInterpolant(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case fe:t=this.InterpolantFactoryMethodDiscrete;break;case ve:t=this.InterpolantFactoryMethodLinear;break;case Ee:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("THREE.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return fe;case this.InterpolantFactoryMethodLinear:return ve;case this.InterpolantFactoryMethodSmooth:return Ee}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){const i=this.times,n=i.length;let r=0,a=n-1;for(;r!==n&&i[r]<e;)++r;for(;-1!==a&&i[a]>t;)--a;if(++a,0!==r||a!==n){r>=a&&(a=Math.max(a,1),r=a-1);const e=this.getValueSize();this.times=arraySlice(i,r,a),this.values=arraySlice(this.values,r*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){const n=i[t];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,n),e=!1;break}if(null!==a&&a>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,n,a),e=!1;break}a=n}if(void 0!==n&&isTypedArray(n))for(let t=0,i=n.length;t!==i;++t){const i=n[t];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,i),e=!1;break}}return e}optimize(){const e=arraySlice(this.times),t=arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===Ee,r=e.length-1;let a=1;for(let o=1;o<r;++o){let r=!1;const l=e[o];if(l!==e[o+1]&&(1!==o||l!==e[0]))if(n)r=!0;else{const e=o*i,n=e-i,a=e+i;for(let o=0;o!==i;++o){const i=t[e+o];if(i!==t[n+o]||i!==t[a+o]){r=!0;break}}}if(r){if(o!==a){e[a]=e[o];const n=o*i,r=a*i;for(let e=0;e!==i;++e)t[r+e]=t[n+e]}++a}}if(r>0){e[a]=e[r];for(let e=r*i,n=a*i,o=0;o!==i;++o)t[n+o]=t[e+o];++a}return a!==e.length?(this.times=arraySlice(e,0,a),this.values=arraySlice(t,0,a*i)):(this.times=e,this.values=t),this}clone(){const e=arraySlice(this.times,0),t=arraySlice(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}KeyframeTrack.prototype.TimeBufferType=Float32Array,KeyframeTrack.prototype.ValueBufferType=Float32Array,KeyframeTrack.prototype.DefaultInterpolation=ve;class BooleanKeyframeTrack extends KeyframeTrack{}BooleanKeyframeTrack.prototype.ValueTypeName="bool",BooleanKeyframeTrack.prototype.ValueBufferType=Array,BooleanKeyframeTrack.prototype.DefaultInterpolation=fe,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class ColorKeyframeTrack extends KeyframeTrack{}ColorKeyframeTrack.prototype.ValueTypeName="color";class NumberKeyframeTrack extends KeyframeTrack{}NumberKeyframeTrack.prototype.ValueTypeName="number";class QuaternionLinearInterpolant extends Interpolant{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(i-t)/(n-t);let c=e*o;for(let e=c+o;c!==e;c+=4)Quaternion.slerpFlat(r,0,a,c-o,a,c,l);return r}}class QuaternionKeyframeTrack extends KeyframeTrack{InterpolantFactoryMethodLinear(e){return new QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),e)}}QuaternionKeyframeTrack.prototype.ValueTypeName="quaternion",QuaternionKeyframeTrack.prototype.DefaultInterpolation=ve,QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class StringKeyframeTrack extends KeyframeTrack{}StringKeyframeTrack.prototype.ValueTypeName="string",StringKeyframeTrack.prototype.ValueBufferType=Array,StringKeyframeTrack.prototype.DefaultInterpolation=fe,StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear=void 0,StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth=void 0;class VectorKeyframeTrack extends KeyframeTrack{}VectorKeyframeTrack.prototype.ValueTypeName="vector";class AnimationClip{constructor(e,t=-1,i,n=2500){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,n=1/(e.fps||1);for(let e=0,r=i.length;e!==r;++e)t.push(parseKeyframeTrack(i[e]).scale(n));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,n=i.length;e!==n;++e)t.push(KeyframeTrack.toJSON(i[e]));return n}static CreateFromMorphTargetSequence(e,t,i,n){const r=t.length,a=[];for(let e=0;e<r;e++){let o=[],l=[];o.push((e+r-1)%r,e,(e+1)%r),l.push(0,1,0);const c=getKeyframeOrder(o);o=sortedArray(o,1,c),l=sortedArray(l,1,c),n||0!==o[0]||(o.push(r),l.push(l[0])),a.push(new NumberKeyframeTrack(".morphTargetInfluences["+t[e].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const t=e;i=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const n={},r=/^([\w-]*?)([\d]+)$/;for(let t=0,i=e.length;t<i;t++){const i=e[t],a=i.name.match(r);if(a&&a.length>1){const e=a[1];let t=n[e];t||(n[e]=t=[]),t.push(i)}}const a=[];for(const e in n)a.push(this.CreateFromMorphTargetSequence(e,n[e],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const addNonemptyTrack=function(e,t,i,n,r){if(0!==i.length){const a=[],o=[];flattenJSON(i,a,o,n),0!==a.length&&r.push(new e(t,a,o))}},i=[],n=e.name||"default",r=e.fps||30,a=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e<l.length;e++){const n=l[e].keys;if(n&&0!==n.length)if(n[0].morphTargets){const e={};let t;for(t=0;t<n.length;t++)if(n[t].morphTargets)for(let i=0;i<n[t].morphTargets.length;i++)e[n[t].morphTargets[i]]=-1;for(const r in e){const e=[],a=[];for(let i=0;i!==n[t].morphTargets.length;++i){const i=n[t];e.push(i.time),a.push(i.morphTarget===r?1:0)}i.push(new NumberKeyframeTrack(".morphTargetInfluence["+r+"]",e,a))}o=e.length*r}else{const r=".bones["+t[e].name+"]";addNonemptyTrack(VectorKeyframeTrack,r+".position",n,"pos",i),addNonemptyTrack(QuaternionKeyframeTrack,r+".quaternion",n,"rot",i),addNonemptyTrack(VectorKeyframeTrack,r+".scale",n,"scl",i)}}if(0===i.length)return null;return new this(n,o,i,a)}resetDuration(){let e=0;for(let t=0,i=this.tracks.length;t!==i;++t){const i=this.tracks[t];e=Math.max(e,i.times[i.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function parseKeyframeTrack(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=function getTrackTypeForValueTypeName(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return NumberKeyframeTrack;case"vector":case"vector2":case"vector3":case"vector4":return VectorKeyframeTrack;case"color":return ColorKeyframeTrack;case"quaternion":return QuaternionKeyframeTrack;case"bool":case"boolean":return BooleanKeyframeTrack;case"string":return StringKeyframeTrack}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],i=[];flattenJSON(e.keys,t,i,"value"),e.times=t,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const sr={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class LoadingManager{constructor(e,t,i){const n=this;let r,a=!1,o=0,l=0;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){l++,!1===a&&void 0!==n.onStart&&n.onStart(e,o,l),a=!0},this.itemEnd=function(e){o++,void 0!==n.onProgress&&n.onProgress(e,o,l),o===l&&(a=!1,void 0!==n.onLoad&&n.onLoad())},this.itemError=function(e){void 0!==n.onError&&n.onError(e)},this.resolveURL=function(e){return r?r(e):e},this.setURLModifier=function(e){return r=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){const t=c.indexOf(e);return-1!==t&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,i=c.length;t<i;t+=2){const i=c[t],n=c[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return n}return null}}}const ar=new LoadingManager;class Loader{constructor(e){this.manager=void 0!==e?e:ar,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise((function(n,r){i.load(e,n,t,r)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Loader.DEFAULT_MATERIAL_NAME="__DEFAULT";const or={};class HttpError extends Error{constructor(e,t){super(e),this.response=t}}class FileLoader extends Loader{constructor(e){super(e)}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=sr.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==or[e])return void or[e].push({onLoad:t,onProgress:i,onError:n});or[e]=[],or[e].push({onLoad:t,onProgress:i,onError:n});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const i=or[e],n=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),a=r?parseInt(r):0,o=0!==a;let l=0;const c=new ReadableStream({start(e){!function readData(){n.read().then((({done:t,value:n})=>{if(t)e.close();else{l+=n.byteLength;const t=new ProgressEvent("progress",{lengthComputable:o,loaded:l,total:a});for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onProgress&&n.onProgress(t)}e.enqueue(n),readData()}}))}()}});return new Response(c)}throw new HttpError(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(l){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,o)));case"json":return e.json();default:if(void 0===o)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(o),i=t&&t[1]?t[1].toLowerCase():void 0,n=new TextDecoder(i);return e.arrayBuffer().then((e=>n.decode(e)))}}})).then((t=>{sr.add(e,t);const i=or[e];delete or[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onLoad&&n.onLoad(t)}})).catch((t=>{const i=or[e];if(void 0===i)throw this.manager.itemError(e),t;delete or[e];for(let e=0,n=i.length;e<n;e++){const n=i[e];n.onError&&n.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ImageLoader extends Loader{constructor(e){super(e)}load(e,t,i,n){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=sr.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const o=createElementNS("img");function onImageLoad(){removeEventListeners(),sr.add(e,this),t&&t(this),r.manager.itemEnd(e)}function onImageError(t){removeEventListeners(),n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)}function removeEventListeners(){o.removeEventListener("load",onImageLoad,!1),o.removeEventListener("error",onImageError,!1)}return o.addEventListener("load",onImageLoad,!1),o.addEventListener("error",onImageError,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(e),o.src=e,o}}class DataTextureLoader extends Loader{constructor(e){super(e)}load(e,t,i,n){const r=this,a=new DataTexture,o=new FileLoader(this.manager);return o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setPath(this.path),o.setWithCredentials(r.withCredentials),o.load(e,(function(e){const i=r.parse(e);i&&(void 0!==i.image?a.image=i.image:void 0!==i.data&&(a.image.width=i.width,a.image.height=i.height,a.image.data=i.data),a.wrapS=void 0!==i.wrapS?i.wrapS:I,a.wrapT=void 0!==i.wrapT?i.wrapT:I,a.magFilter=void 0!==i.magFilter?i.magFilter:O,a.minFilter=void 0!==i.minFilter?i.minFilter:O,a.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace?a.colorSpace=i.colorSpace:void 0!==i.encoding&&(a.encoding=i.encoding),void 0!==i.flipY&&(a.flipY=i.flipY),void 0!==i.format&&(a.format=i.format),void 0!==i.type&&(a.type=i.type),void 0!==i.mipmaps&&(a.mipmaps=i.mipmaps,a.minFilter=W),1===i.mipmapCount&&(a.minFilter=O),void 0!==i.generateMipmaps&&(a.generateMipmaps=i.generateMipmaps),a.needsUpdate=!0,t&&t(a,i))}),i,n),a}}class TextureLoader extends Loader{constructor(e){super(e)}load(e,t,i,n){const r=new Texture$1,a=new ImageLoader(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),i,n),r}}class Light extends Object3D{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Color(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}const lr=new Matrix4,cr=new Vector3,hr=new Vector3;class LightShadow{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Vector2(512,512),this.map=null,this.mapPass=null,this.matrix=new Matrix4,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Frustum,this._frameExtents=new Vector2(1,1),this._viewportCount=1,this._viewports=[new Vector4(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;cr.setFromMatrixPosition(e.matrixWorld),t.position.copy(cr),hr.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(hr),t.updateMatrixWorld(),lr.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lr),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(lr)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class SpotLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=2*qe*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;i===t.fov&&n===t.aspect&&r===t.far||(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class SpotLight extends Light{constructor(e,t,i=0,n=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.distance=i,this.angle=n,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new SpotLightShadow}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const ur=new Matrix4,dr=new Vector3,Ar=new Vector3;class PointLightShadow extends LightShadow{constructor(){super(new PerspectiveCamera(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Vector2(4,2),this._viewportCount=6,this._viewports=[new Vector4(2,1,1,1),new Vector4(0,1,1,1),new Vector4(3,1,1,1),new Vector4(1,1,1,1),new Vector4(3,0,1,1),new Vector4(1,0,1,1)],this._cubeDirections=[new Vector3(1,0,0),new Vector3(-1,0,0),new Vector3(0,0,1),new Vector3(0,0,-1),new Vector3(0,1,0),new Vector3(0,-1,0)],this._cubeUps=[new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,1,0),new Vector3(0,0,1),new Vector3(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),dr.setFromMatrixPosition(e.matrixWorld),i.position.copy(dr),Ar.copy(i.position),Ar.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Ar),i.updateMatrixWorld(),n.makeTranslation(-dr.x,-dr.y,-dr.z),ur.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ur)}}class PointLight extends Light{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new PointLightShadow}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class DirectionalLightShadow extends LightShadow{constructor(){super(new OrthographicCamera(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class DirectionalLight extends Light{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Object3D.DEFAULT_UP),this.updateMatrix(),this.target=new Object3D,this.shadow=new DirectionalLightShadow}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class SphericalHarmonics3{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Vector3)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,n=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*n),t.addScaledVector(a[2],.488603*r),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],i*n*1.092548),t.addScaledVector(a[5],n*r*1.092548),t.addScaledVector(a[6],.315392*(3*r*r-1)),t.addScaledVector(a[7],i*r*1.092548),t.addScaledVector(a[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){const i=e.x,n=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*n),t.addScaledVector(a[2],1.023328*r),t.addScaledVector(a[3],1.023328*i),t.addScaledVector(a[4],.858086*i*n),t.addScaledVector(a[5],.858086*n*r),t.addScaledVector(a[6],.743125*r*r-.247708),t.addScaledVector(a[7],.858086*i*r),t.addScaledVector(a[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+3*n);return this}toArray(e=[],t=0){const i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+3*n);return e}static getBasisAt(e,t){const i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}}class LightProbe extends Light{constructor(e=new SphericalHarmonics3,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class LoaderUtils{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class ImageBitmapLoader extends Loader{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=sr.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader,fetch(e,o).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(i){sr.add(e,i),t&&t(i),r.manager.itemEnd(e)})).catch((function(t){n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}}class PropertyMixer{constructor(e,t,i){let n,r,a;switch(this.binding=e,this.valueSize=i,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=r,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,n=this.valueSize,r=e*n+n;let a=this.cumulativeWeight;if(0===a){for(let e=0;e!==n;++e)i[r+e]=i[e];a=t}else{a+=t;const e=t/a;this._mixBufferRegion(i,r,0,e,n)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,n=e*t+t,r=this.cumulativeWeight,a=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const e=t*this._origIndex;this._mixBufferRegion(i,n,e,1-r,t)}a>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(i[e]!==i[e+t]){o.setValue(i,n);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let e=i,r=n;e!==r;++e)t[e]=t[n+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let n=0;n!==r;++n)e[t+n]=e[i+n]}_slerp(e,t,i,n){Quaternion.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){const a=this._workIndex*r;Quaternion.multiplyQuaternionsFlat(e,a,e,t,e,i),Quaternion.slerpFlat(e,t,e,t,e,a,n)}_lerp(e,t,i,n,r){const a=1-n;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*a+e[i+o]*n}}_lerpAdditive(e,t,i,n,r){for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]+e[i+a]*n}}}const pr="\\[\\]\\.:\\/",mr=new RegExp("["+pr+"]","g"),gr="[^"+pr+"]",fr="[^"+pr.replace("\\.","")+"]",vr=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",gr)+/(WCOD+)?/.source.replace("WCOD",fr)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gr)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gr)+"$"),Er=["material","materials","bones","map"];class PropertyBinding{constructor(e,t,i){this.path=t,this.parsedPath=i||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new PropertyBinding.Composite(e,t,i):new PropertyBinding(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(mr,"")}static parseTrackName(e){const t=vr.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const e=i.nodeName.substring(n+1);-1!==Er.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){const searchNodeSubtree=function(e){for(let i=0;i<e.length;i++){const n=e[i];if(n.name===t||n.uuid===t)return n;const r=searchNodeSubtree(n.children);if(r)return r}return null},i=searchNodeSubtree(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,i=t.objectName,n=t.propertyName;let r=t.propertyIndex;if(e||(e=PropertyBinding.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(i){let n=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===n){n=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==n){if(void 0===e[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[n]}}const a=e[n];if(void 0===a){const i=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" but it wasn't found.",e)}let o=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?o=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===n){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[r]&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else void 0!==a.fromArray&&void 0!==a.toArray?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=n;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}PropertyBinding.Composite=class Composite{constructor(e,t,i){const n=i||PropertyBinding.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},PropertyBinding.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},PropertyBinding.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},PropertyBinding.prototype.GetterByBindingType=[PropertyBinding.prototype._getValue_direct,PropertyBinding.prototype._getValue_array,PropertyBinding.prototype._getValue_arrayElement,PropertyBinding.prototype._getValue_toArray],PropertyBinding.prototype.SetterByBindingTypeAndVersioning=[[PropertyBinding.prototype._setValue_direct,PropertyBinding.prototype._setValue_direct_setNeedsUpdate,PropertyBinding.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_array,PropertyBinding.prototype._setValue_array_setNeedsUpdate,PropertyBinding.prototype._setValue_array_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_arrayElement,PropertyBinding.prototype._setValue_arrayElement_setNeedsUpdate,PropertyBinding.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[PropertyBinding.prototype._setValue_fromArray,PropertyBinding.prototype._setValue_fromArray_setNeedsUpdate,PropertyBinding.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class AnimationAction{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;const r=t.tracks,a=r.length,o=new Array(a),l={endingStart:ye,endingEnd:ye};for(let e=0;e!==a;++e){const t=r[e].createInterpolant(null);o[e]=t,t.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=me,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const i=this._clip.duration,n=e._clip.duration,r=n/i,a=i/n;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const n=this._mixer,r=n.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=r,l[1]=r+i,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,n){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const n=(e-r)*i;n<0||0===i?t=0:(this._startTime=null,t=i*n)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let i=0,n=e.length;i!==n;++i)e[i].evaluate(a),t[i].accumulateAdditive(o);else for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(a),t[i].accumulate(n,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(null!==i){t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let n=this.time+e,r=this._loopCount;const a=i===ge;if(0===e)return-1===r||!a||1&~r?n:t-n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),n>=t||n<0){const i=Math.floor(n/t);n-=t*i,r+=Math.abs(i);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(a&&!(1&~r))return t-n}return n}_setEndings(e,t,i){const n=this._interpolantSettings;i?(n.endingStart=_e,n.endingEnd=_e):(n.endingStart=e?this.zeroSlopeAtStart?_e:ye:xe,n.endingEnd=t?this.zeroSlopeAtEnd?_e:ye:xe)}_scheduleFading(e,t,i){const n=this._mixer,r=n.time;let a=this._weightInterpolant;null===a&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=r,l[0]=t,o[1]=r+e,l[1]=i,this}}const yr=new Float32Array(1);class AnimationMixer extends EventDispatcher{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,a=e._propertyBindings,o=e._interpolants,l=i.uuid,c=this._bindingsByRootAndName;let h=c[l];void 0===h&&(h={},c[l]=h);for(let e=0;e!==r;++e){const r=n[e],c=r.name;let d=h[c];if(void 0!==d)++d.referenceCount,a[e]=d;else{if(d=a[e],void 0!==d){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,l,c));continue}const n=t&&t._propertyBindings[e].binding.parsedPath;d=new PropertyMixer(PropertyBinding.create(i,c,n),r.ValueTypeName,r.getValueSize()),++d.referenceCount,this._addInactiveBinding(d,l,c),a[e]=d}o[e].resultBuffer=d.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,t)}const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t<this._nActiveActions}_addInactiveAction(e,t,i){const n=this._actions,r=this._actionsByClip;let a=r[t];if(void 0===a)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=a;else{const t=a.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=n.length,n.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,a=this._actionsByClip,o=a[r],l=o.knownActions,c=l[l.length-1],h=e._byClipCacheIndex;c._byClipCacheIndex=h,l[h]=c,l.pop(),e._byClipCacheIndex=null;delete o.actionByRoot[(e._localRoot||this._root).uuid],0===l.length&&delete a[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){const i=t[e];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){const n=this._bindingsByRootAndName,r=this._bindings;let a=n[t];void 0===a&&(a={},n[t]=a),a[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,a=this._bindingsByRootAndName,o=a[n],l=t[t.length-1],c=e._cacheIndex;l._cacheIndex=c,t[c]=l,t.pop(),delete o[r],0===Object.keys(o).length&&delete a[n]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return void 0===i&&(i=new LinearInterpolant(new Float32Array(2),new Float32Array(2),1,yr),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){const n=t||this._root,r=n.uuid;let a="string"==typeof e?AnimationClip.findByName(n,e):e;const o=null!==a?a.uuid:e,l=this._actionsByClip[o];let c=null;if(void 0===i&&(i=null!==a?a.blendMode:Se),void 0!==l){const e=l.actionByRoot[r];if(void 0!==e&&e.blendMode===i)return e;c=l.knownActions[0],null===a&&(a=c._clip)}if(null===a)return null;const h=new AnimationAction(this,a,t,i);return this._bindAction(h,c),this._addInactiveAction(h,o,r),h}existingAction(e,t){const i=t||this._root,n=i.uuid,r="string"==typeof e?AnimationClip.findByName(i,e):e,a=r?r.uuid:e,o=this._actionsByClip[a];return void 0!==o&&o.actionByRoot[n]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;t>=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let o=0;o!==i;++o){t[o]._update(n,e,r,a)}const o=this._bindings,l=this._nActiveBindings;for(let e=0;e!==l;++e)o[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){const e=r.knownActions;for(let i=0,n=e.length;i!==n;++i){const n=e[i];this._deactivateAction(n);const r=n._cacheIndex,a=t[t.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,a._cacheIndex=r,t[r]=a,t.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const e in i){const n=i[e].actionByRoot[t];void 0!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}const n=this._bindingsByRootAndName[t];if(void 0!==n)for(const e in n){const t=n[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}}class Uniform{constructor(e){this.value=e}clone(){return new Uniform(void 0===this.value.clone?this.value:this.value.clone())}}function ascSort(e,t){return e.distance-t.distance}function intersectObject(e,t,i,n){if(e.layers.test(t.layers)&&e.raycast(t,i),!0===n){const n=e.children;for(let e=0,r=n.length;e<r;e++)intersectObject(n[e],t,i,!0)}}class Spherical{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(clamp$1(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t)
/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */;const _r=window,xr=_r.ShadowRoot&&(void 0===_r.ShadyCSS||_r.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Sr=Symbol(),Cr=new WeakMap;class o$5{constructor(e,t,i){if(this._$cssResult$=!0,i!==Sr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(xr&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=Cr.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Cr.set(t,e))}return e}toString(){return this.cssText}}const Mr=xr?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new o$5("string"==typeof e?e:e+"",void 0,Sr))(t)})(e):e
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */;var br;const Ir=window,wr=Ir.trustedTypes,Tr=wr?wr.emptyScript:"",Br=Ir.reactiveElementPolyfillSupport,Rr={toAttribute(e,t){switch(t){case Boolean:e=e?Tr:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},a$3=(e,t)=>t!==e&&(t==t||e==e),Lr={attribute:!0,type:String,converter:Rr,reflect:!1,hasChanged:a$3},Dr="finalized";class u$2 extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const n=this._$Ep(i,t);void 0!==n&&(this._$Ev.set(n,i),e.push(n))})),e}static createProperty(e,t=Lr){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,n=this.getPropertyDescriptor(e,i,t);void 0!==n&&Object.defineProperty(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(n){const r=this[e];this[t]=n,this.requestUpdate(e,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Lr}static finalize(){if(this.hasOwnProperty(Dr))return!1;this[Dr]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(Mr(e))}else void 0!==e&&t.push(Mr(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{xr?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const i=document.createElement("style"),n=_r.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=t.cssText,e.appendChild(i)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=Lr){var n;const r=this.constructor._$Ep(e,i);if(void 0!==r&&!0===i.reflect){const a=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:Rr).toAttribute(t,i.type);this._$El=e,null==a?this.removeAttribute(r):this.setAttribute(r,a),this._$El=null}}_$AK(e,t){var i;const n=this.constructor,r=n._$Ev.get(e);if(void 0!==r&&this._$El!==r){const e=n.getPropertyOptions(r),a="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(i=e.converter)||void 0===i?void 0:i.fromAttribute)?e.converter:Rr;this._$El=r,this[r]=a.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,i){let n=!0;void 0!==e&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||a$3)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(i)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
var Ur;u$2[Dr]=!0,u$2.elementProperties=new Map,u$2.elementStyles=[],u$2.shadowRootOptions={mode:"open"},null==Br||Br({ReactiveElement:u$2}),(null!==(br=Ir.reactiveElementVersions)&&void 0!==br?br:Ir.reactiveElementVersions=[]).push("1.6.2");const Pr=window,Fr=Pr.trustedTypes,Nr=Fr?Fr.createPolicy("lit-html",{createHTML:e=>e}):void 0,Qr="$lit$",Or=`lit$${(Math.random()+"").slice(9)}$`,kr="?"+Or,Gr=`<${kr}>`,Vr=document,u$1=()=>Vr.createComment(""),d$1=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Hr=Array.isArray,zr="[ \t\n\f\r]",Wr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,qr=/-->/g,Xr=/>/g,jr=RegExp(`>|${zr}(?:([^\\s"'>=/]+)(${zr}*=${zr}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Yr=/'/g,Kr=/"/g,$r=/^(?:script|style|textarea|title)$/i,Jr=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),Zr=Symbol.for("lit-noChange"),es=Symbol.for("lit-nothing"),ts=new WeakMap,is=Vr.createTreeWalker(Vr,129,null,!1);function P(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Nr?Nr.createHTML(t):t}const V=(e,t)=>{const i=e.length-1,n=[];let r,a=2===t?"<svg>":"",o=Wr;for(let t=0;t<i;t++){const i=e[t];let l,c,h=-1,d=0;for(;d<i.length&&(o.lastIndex=d,c=o.exec(i),null!==c);)d=o.lastIndex,o===Wr?"!--"===c[1]?o=qr:void 0!==c[1]?o=Xr:void 0!==c[2]?($r.test(c[2])&&(r=RegExp("</"+c[2],"g")),o=jr):void 0!==c[3]&&(o=jr):o===jr?">"===c[0]?(o=null!=r?r:Wr,h=-1):void 0===c[1]?h=-2:(h=o.lastIndex-c[2].length,l=c[1],o=void 0===c[3]?jr:'"'===c[3]?Kr:Yr):o===Kr||o===Yr?o=jr:o===qr||o===Xr?o=Wr:(o=jr,r=void 0);const A=o===jr&&e[t+1].startsWith("/>")?" ":"";a+=o===Wr?i+Gr:h>=0?(n.push(l),i.slice(0,h)+Qr+i.slice(h)+Or+A):i+Or+(-2===h?(n.push(void 0),t):A)}return[P(e,a+(e[i]||"<?>")+(2===t?"</svg>":"")),n]};class N{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let r=0,a=0;const o=e.length-1,l=this.parts,[c,h]=V(e,t);if(this.el=N.createElement(c,i),is.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(n=is.nextNode())&&l.length<o;){if(1===n.nodeType){if(n.hasAttributes()){const e=[];for(const t of n.getAttributeNames())if(t.endsWith(Qr)||t.startsWith(Or)){const i=h[a++];if(e.push(t),void 0!==i){const e=n.getAttribute(i.toLowerCase()+Qr).split(Or),t=/([.?@])?(.*)/.exec(i);l.push({type:1,index:r,name:t[2],strings:e,ctor:"."===t[1]?H:"?"===t[1]?L:"@"===t[1]?z:k})}else l.push({type:6,index:r})}for(const t of e)n.removeAttribute(t)}if($r.test(n.tagName)){const e=n.textContent.split(Or),t=e.length-1;if(t>0){n.textContent=Fr?Fr.emptyScript:"";for(let i=0;i<t;i++)n.append(e[i],u$1()),is.nextNode(),l.push({type:2,index:++r});n.append(e[t],u$1())}}}else if(8===n.nodeType)if(n.data===kr)l.push({type:2,index:r});else{let e=-1;for(;-1!==(e=n.data.indexOf(Or,e+1));)l.push({type:7,index:r}),e+=Or.length-1}r++}}static createElement(e,t){const i=Vr.createElement("template");return i.innerHTML=e,i}}function S$1(e,t,i=e,n){var r,a,o,l;if(t===Zr)return t;let c=void 0!==n?null===(r=i._$Co)||void 0===r?void 0:r[n]:i._$Cl;const h=d$1(t)?void 0:t._$litDirective$;return(null==c?void 0:c.constructor)!==h&&(null===(a=null==c?void 0:c._$AO)||void 0===a||a.call(c,!1),void 0===h?c=void 0:(c=new h(e),c._$AT(e,i,n)),void 0!==n?(null!==(o=(l=i)._$Co)&&void 0!==o?o:l._$Co=[])[n]=c:i._$Cl=c),void 0!==c&&(t=S$1(e,c._$AS(e,t.values),c,n)),t}class M{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:i},parts:n}=this._$AD,r=(null!==(t=null==e?void 0:e.creationScope)&&void 0!==t?t:Vr).importNode(i,!0);is.currentNode=r;let a=is.nextNode(),o=0,l=0,c=n[0];for(;void 0!==c;){if(o===c.index){let t;2===c.type?t=new R(a,a.nextSibling,this,e):1===c.type?t=new c.ctor(a,c.name,c.strings,this,e):6===c.type&&(t=new Z(a,this,e)),this._$AV.push(t),c=n[++l]}o!==(null==c?void 0:c.index)&&(a=is.nextNode(),o++)}return is.currentNode=Vr,r}v(e){let t=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}}class R{constructor(e,t,i,n){var r;this.type=2,this._$AH=es,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cp=null===(r=null==n?void 0:n.isConnected)||void 0===r||r}get _$AU(){var e,t;return null!==(t=null===(e=this._$AM)||void 0===e?void 0:e._$AU)&&void 0!==t?t:this._$Cp}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===(null==e?void 0:e.nodeType)&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=S$1(this,e,t),d$1(e)?e===es||null==e||""===e?(this._$AH!==es&&this._$AR(),this._$AH=es):e!==this._$AH&&e!==Zr&&this._(e):void 0!==e._$litType$?this.g(e):void 0!==e.nodeType?this.$(e):(e=>Hr(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==es&&d$1(this._$AH)?this._$AA.nextSibling.data=e:this.$(Vr.createTextNode(e)),this._$AH=e}g(e){var t;const{values:i,_$litType$:n}=e,r="number"==typeof n?this._$AC(e):(void 0===n.el&&(n.el=N.createElement(P(n.h,n.h[0]),this.options)),n);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===r)this._$AH.v(i);else{const e=new M(r,this),t=e.u(this.options);e.v(i),this.$(t),this._$AH=e}}_$AC(e){let t=ts.get(e.strings);return void 0===t&&ts.set(e.strings,t=new N(e)),t}T(e){Hr(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,n=0;for(const r of e)n===t.length?t.push(i=new R(this.k(u$1()),this.k(u$1()),this,this.options)):i=t[n],i._$AI(r),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,t);e&&e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cp=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class k{constructor(e,t,i,n,r){this.type=1,this._$AH=es,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=es}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,n){const r=this.strings;let a=!1;if(void 0===r)e=S$1(this,e,t,0),a=!d$1(e)||e!==this._$AH&&e!==Zr,a&&(this._$AH=e);else{const n=e;let o,l;for(e=r[0],o=0;o<r.length-1;o++)l=S$1(this,n[i+o],t,o),l===Zr&&(l=this._$AH[o]),a||(a=!d$1(l)||l!==this._$AH[o]),l===es?e=es:e!==es&&(e+=(null!=l?l:"")+r[o+1]),this._$AH[o]=l}a&&!n&&this.j(e)}j(e){e===es?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=e?e:"")}}class H extends k{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===es?void 0:e}}const ns=Fr?Fr.emptyScript:"";class L extends k{constructor(){super(...arguments),this.type=4}j(e){e&&e!==es?this.element.setAttribute(this.name,ns):this.element.removeAttribute(this.name)}}class z extends k{constructor(e,t,i,n,r){super(e,t,i,n,r),this.type=5}_$AI(e,t=this){var i;if((e=null!==(i=S$1(this,e,t,0))&&void 0!==i?i:es)===Zr)return;const n=this._$AH,r=e===es&&n!==es||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,a=e!==es&&(n===es||r);r&&this.element.removeEventListener(this.name,this,n),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(t=this.options)||void 0===t?void 0:t.host)&&void 0!==i?i:this.element,e):this._$AH.handleEvent(e)}}class Z{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){S$1(this,e)}}const rs=Pr.litHtmlPolyfillSupport;null==rs||rs(N,R),(null!==(Ur=Pr.litHtmlVersions)&&void 0!==Ur?Ur:Pr.litHtmlVersions=[]).push("2.7.5");const D=(e,t,i)=>{var n,r;const a=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:t;let o=a._$litPart$;if(void 0===o){const e=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;a._$litPart$=o=new R(t.insertBefore(u$1(),e),e,void 0,null!=i?i:{})}return o._$AI(e),o},ss=window,as=ss.ShadowRoot&&(void 0===ss.ShadyCSS||ss.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,os=Symbol(),ls=new WeakMap;
/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */class o$2{constructor(e,t,i){if(this._$cssResult$=!0,i!==os)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(as&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=ls.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&ls.set(t,e))}return e}toString(){return this.cssText}}const cs=as?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new o$2("string"==typeof e?e:e+"",void 0,os))(t)})(e):e
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */;var hs;const us=window,ds=us.trustedTypes,As=ds?ds.emptyScript:"",ps=us.reactiveElementPolyfillSupport,ms={toAttribute(e,t){switch(t){case Boolean:e=e?As:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},a$1=(e,t)=>t!==e&&(t==t||e==e),gs={attribute:!0,type:String,converter:ms,reflect:!1,hasChanged:a$1},fs="finalized";class u extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const n=this._$Ep(i,t);void 0!==n&&(this._$Ev.set(n,i),e.push(n))})),e}static createProperty(e,t=gs){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,n=this.getPropertyDescriptor(e,i,t);void 0!==n&&Object.defineProperty(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(n){const r=this[e];this[t]=n,this.requestUpdate(e,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||gs}static finalize(){if(this.hasOwnProperty(fs))return!1;this[fs]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(cs(e))}else void 0!==e&&t.push(cs(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{as?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const i=document.createElement("style"),n=ss.litNonce;void 0!==n&&i.setAttribute("nonce",n),i.textContent=t.cssText,e.appendChild(i)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=gs){var n;const r=this.constructor._$Ep(e,i);if(void 0!==r&&!0===i.reflect){const a=(void 0!==(null===(n=i.converter)||void 0===n?void 0:n.toAttribute)?i.converter:ms).toAttribute(t,i.type);this._$El=e,null==a?this.removeAttribute(r):this.setAttribute(r,a),this._$El=null}}_$AK(e,t){var i;const n=this.constructor,r=n._$Ev.get(e);if(void 0!==r&&this._$El!==r){const e=n.getPropertyOptions(r),a="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(i=e.converter)||void 0===i?void 0:i.fromAttribute)?e.converter:ms;this._$El=r,this[r]=a.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,i){let n=!0;void 0!==e&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||a$1)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(i)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}}
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
var vs,Es;u[fs]=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==ps||ps({ReactiveElement:u}),(null!==(hs=us.reactiveElementVersions)&&void 0!==hs?hs:us.reactiveElementVersions=[]).push("1.6.2");class s extends u{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const i=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=i.firstChild),i}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=D(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return Zr}}s.finalized=!0,s._$litElement$=!0,null===(vs=globalThis.litElementHydrateSupport)||void 0===vs||vs.call(globalThis,{LitElement:s});const ys=globalThis.litElementPolyfillSupport;null==ys||ys({LitElement:s}),(null!==(Es=globalThis.litElementVersions)&&void 0!==Es?Es:globalThis.litElementVersions=[]).push("3.3.2");
/* @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 _s=null!=navigator.xr&&null!=self.XRSession&&null!=navigator.xr.isSessionSupported,xs=_s&&null!=self.XRSession.prototype.requestHitTestSource,Ss=null!=self.ResizeObserver,Cs=null!=self.IntersectionObserver,Ms=xs;(()=>{const e=navigator.userAgent||navigator.vendor||self.opera;let t=!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(e)||/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(e.substr(0,4)))&&(t=!0)})(),/\bCrOS\b/.test(navigator.userAgent);const bs=/android/i.test(navigator.userAgent),Is=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;/Safari\//.test(navigator.userAgent);const ws=/firefox/i.test(navigator.userAgent),Ts=/OculusBrowser/.test(navigator.userAgent);Is&&/CriOS\//.test(navigator.userAgent);const Bs=bs&&!ws&&!Ts,Rs=Boolean(window.webkit&&window.webkit.messageHandlers),Ls=(()=>{if(Is){if(Rs)return Boolean(/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent));{const e=document.createElement("a");return Boolean(e.relList&&e.relList.supports&&e.relList.supports("ar"))}}return!1})(),deserializeUrl=e=>e&&"null"!==e?toFullUrl(e):null,assertIsArCandidate=()=>{if(Ms)return;const e=[];throw _s||e.push("WebXR Device API"),xs||e.push("WebXR Hit Test API"),new Error(`The following APIs are required for AR, but are missing in this browser: ${e.join(", ")}`)},toFullUrl=e=>new URL(e,window.location.toString()).toString(),debounce=(e,t)=>{let i=null;return(...n)=>{null!=i&&self.clearTimeout(i),i=self.setTimeout((()=>{i=null,e(...n)}),t)}},clamp=(e,t,i)=>Math.max(t,Math.min(i,e)),Ds=(()=>{const e=(()=>{var e;if(null===(e=document.documentElement.getAttribute("itemtype"))||void 0===e?void 0:e.includes("schema.org/SearchResultsPage"))return!0;const t=null!=document.head?Array.from(document.head.querySelectorAll("meta")):[];for(const e of t)if("viewport"===e.name)return!0;return!1})();return e||console.warn('No <meta name="viewport"> detected; <model-viewer> will cap pixel density at 1.'),()=>e?window.devicePixelRatio:1})(),Us=(()=>{const e=new RegExp("[?&]model-viewer-debug-mode(&|$)");return()=>self.ModelViewerElement&&self.ModelViewerElement.debugMode||self.location&&self.location.search&&self.location.search.match(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.
 */
var __decorate$7=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};const Ps=Symbol("currentEnvironmentMap"),Fs=Symbol("currentBackground"),Ns=Symbol("updateEnvironment"),Qs=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 Os=Jr`
<style>
:host {
  display: block;
  position: relative;
  contain: strict;
  width: 300px;
  height: 150px;
}

.container {
  position: relative;
  overflow: hidden;
}

.userInput {
  width: 100%;
  height: 100%;
  display: none;
  position: relative;
  outline-offset: -1px;
  outline-width: 1px;
}

canvas {
  position: absolute;
  display: none;
  pointer-events: none;
  /* NOTE(cdata): Chrome 76 and below apparently have a bug
   * that causes our canvas not to display pixels unless it is
   * on its own render layer
   * @see https://github.com/google/model-viewer/pull/755#issuecomment-536597893
   */
  transform: translateZ(0);
}

.show {
  display: block;
}

/* Adapted from HTML5 Boilerplate
 *
 * @see https://github.com/h5bp/html5-boilerplate/blob/ceb4620c78fc82e13534fc44202a3f168754873f/dist/css/main.css#L122-L133 */
.screen-reader-only {
  border: 0;
  left: 0;
  top: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
  pointer-events: none;
}

.slot {
  position: absolute;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.slot > * {
  pointer-events: initial;
}

.annotation-wrapper ::slotted(*) {
  opacity: var(--max-hotspot-opacity, 1);
  transition: opacity 0.3s;
}

.pointer-tumbling .annotation-wrapper ::slotted(*) {
  pointer-events: none;
}

.annotation-wrapper ::slotted(*) {
  pointer-events: initial;
}

.annotation-wrapper.hide ::slotted(*) {
  opacity: var(--min-hotspot-opacity, 0.25);
}

.slot.poster {
  display: none;
  background-color: inherit;
}

.slot.poster.show {
  display: inherit;
}

.slot.poster > * {
  pointer-events: initial;
}

.slot.poster:not(.show) > * {
  pointer-events: none;
}

#default-poster {
  width: 100%;
  height: 100%;
  /* The default poster is a <button> so we need to set display
   * to prevent it from being affected by text-align: */
  display: block;
  position: absolute;
  border: none;
  padding: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: #fff0;
}

#default-progress-bar {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

#default-progress-bar > .bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--progress-bar-height, 5px);
  background-color: var(--progress-bar-color, rgba(0, 0, 0, 0.4));
  transition: transform 0.09s;
  transform-origin: top left;
  transform: scaleX(0);
  overflow: hidden;
}

#default-progress-bar > .bar.hide {
  transition: opacity 0.3s 1s;
  opacity: 0;
}

.centered {
  align-items: center;
  justify-content: center;
}

.cover {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.slot.interaction-prompt {
  display: var(--interaction-prompt-display, flex);
  overflow: hidden;
  opacity: 0;
  will-change: opacity;
  transition: opacity 0.3s;
}

.slot.interaction-prompt.visible {
  opacity: 1;
}

.animated-container {
  will-change: transform, opacity;
  opacity: 0;
  transition: opacity 0.3s;
}

.slot.interaction-prompt > * {
  pointer-events: none;
}

.slot.ar-button {
  -moz-user-select: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;

  display: var(--ar-button-display, block);
}

.slot.ar-button:not(.enabled) {
  display: none;
}

.fab {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  cursor: pointer;
  background-color: #fff;
  box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15);
  border-radius: 100px;
}

.fab > * {
  opacity: 0.87;
}

#default-ar-button {
  position: absolute;
  bottom: 16px;
  right: 16px;
  transform: scale(var(--ar-button-scale, 1));
  transform-origin: bottom right;
}

.slot.pan-target {
  display: block;
  position: absolute;
  width: 0;
  height: 0;
  left: 50%;
  top: 50%;
  transform: translate3d(-50%, -50%, 0);
  background-color: transparent;
  opacity: 0;
  transition: opacity 0.3s;
}

#default-pan-target {
  width: 6px;
  height: 6px;
  border-radius: 6px;
  border: 1px solid white;
  box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.8);
}

.slot.default {
  pointer-events: none;
}

.slot.progress-bar {
  pointer-events: none;
}

.slot.exit-webxr-ar-button {
  pointer-events: none;
}

.slot.exit-webxr-ar-button:not(.enabled) {
  display: none;
}

#default-exit-webxr-ar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  right: 16px;
  width: 40px;
  height: 40px;
  box-sizing: border-box;
}

#default-exit-webxr-ar-button > svg {
  fill: #fff;
}
</style>
<div class="container">
  <div class="userInput" tabindex="0" role="img"
      aria-label="3D model">
      <div class="slot canvas">
        <slot name="canvas">
          <canvas></canvas>
        </slot>
      </div>

  </div>

  <!-- NOTE(cdata): We need to wrap slots because browsers without ShadowDOM
        will have their <slot> elements removed by ShadyCSS -->
  <div class="slot poster">
    <slot name="poster">
      <button type="button" id="default-poster" aria-hidden="true" aria-label="Loading 3D model"></button>
    </slot>
  </div>

  <div class="slot ar-button">
    <slot name="ar-button">
      <a id="default-ar-button" part="default-ar-button" class="fab"
          tabindex="2"
          aria-label="View in your space">
        ${Jr`
<svg version="1.1" id="view_x5F_in_x5F_AR_x5F_icon"
	 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px"
	 viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<rect id="Bounding_Box" x="0" y="0" fill="none" width="24" height="24"/>
<g id="Art_layer">
	<path d="M3,4c0-0.55,0.45-1,1-1h2V1H4C2.35,1,1,2.35,1,4v2h2V4z"/>
	<path d="M20,3c0.55,0,1,0.45,1,1v2h2V4c0-1.65-1.35-3-3-3h-2v2H20z"/>
	<path d="M4,21c-0.55,0-1-0.45-1-1v-2H1v2c0,1.65,1.35,3,3,3h2v-2H4z"/>
	<path d="M20,21c0.55,0,1-0.45,1-1v-2h2v2c0,1.65-1.35,3-3,3h-2v-2H20z"/>
	<g>
		<path d="M18.25,7.6l-5.5-3.18c-0.46-0.27-1.04-0.27-1.5,0L5.75,7.6C5.29,7.87,5,8.36,5,8.9v6.35c0,0.54,0.29,1.03,0.75,1.3
			l5.5,3.18c0.46,0.27,1.04,0.27,1.5,0l5.5-3.18c0.46-0.27,0.75-0.76,0.75-1.3V8.9C19,8.36,18.71,7.87,18.25,7.6z M7,14.96v-4.62
			l4,2.32v4.61L7,14.96z M12,10.93L8,8.61l4-2.31l4,2.31L12,10.93z M13,17.27v-4.61l4-2.32v4.62L13,17.27z"/>
	</g>
</g>
</svg>`}
      </a>
    </slot>
  </div>

  <div class="slot pan-target">
    <slot name="pan-target">
      <div id="default-pan-target">
      </div>
    </slot>
  </div>

  <div class="slot interaction-prompt cover centered">
    <div id="prompt" class="animated-container">
      <slot name="interaction-prompt" aria-hidden="true">
        ${Jr`
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="25" height="36">
    <defs>
        <path id="A" d="M.001.232h24.997V36H.001z" />
    </defs>
    <g transform="translate(-11 -4)" fill="none" fill-rule="evenodd">
        <path fill-opacity="0" fill="#fff" d="M0 0h44v44H0z" />
        <g transform="translate(11 3)">
            <path d="M8.733 11.165c.04-1.108.766-2.027 1.743-2.307a2.54 2.54 0 0 1 .628-.089c.16 0 .314.017.463.044 1.088.2 1.9 1.092 1.9 2.16v8.88h1.26c2.943-1.39 5-4.45 5-8.025a9.01 9.01 0 0 0-1.9-5.56l-.43-.5c-.765-.838-1.683-1.522-2.712-2-1.057-.49-2.226-.77-3.46-.77s-2.4.278-3.46.77c-1.03.478-1.947 1.162-2.71 2l-.43.5a9.01 9.01 0 0 0-1.9 5.56 9.04 9.04 0 0 0 .094 1.305c.03.21.088.41.13.617l.136.624c.083.286.196.56.305.832l.124.333a8.78 8.78 0 0 0 .509.953l.065.122a8.69 8.69 0 0 0 3.521 3.191l1.11.537v-9.178z" fill-opacity=".5" fill="#e4e4e4" />
            <path d="M22.94 26.218l-2.76 7.74c-.172.485-.676.8-1.253.8H12.24c-1.606 0-3.092-.68-3.98-1.82-1.592-2.048-3.647-3.822-6.11-5.27-.095-.055-.15-.137-.152-.23-.004-.1.046-.196.193-.297.56-.393 1.234-.6 1.926-.6a3.43 3.43 0 0 1 .691.069l4.922.994V10.972c0-.663.615-1.203 1.37-1.203s1.373.54 1.373 1.203v9.882h2.953c.273 0 .533.073.757.21l6.257 3.874c.027.017.045.042.07.06.41.296.586.77.426 1.22M4.1 16.614c-.024-.04-.042-.083-.065-.122a8.69 8.69 0 0 1-.509-.953c-.048-.107-.08-.223-.124-.333l-.305-.832c-.058-.202-.09-.416-.136-.624l-.13-.617a9.03 9.03 0 0 1-.094-1.305c0-2.107.714-4.04 1.9-5.56l.43-.5c.764-.84 1.682-1.523 2.71-2 1.058-.49 2.226-.77 3.46-.77s2.402.28 3.46.77c1.03.477 1.947 1.16 2.712 2l.428.5a9 9 0 0 1 1.901 5.559c0 3.577-2.056 6.636-5 8.026h-1.26v-8.882c0-1.067-.822-1.96-1.9-2.16-.15-.028-.304-.044-.463-.044-.22 0-.427.037-.628.09-.977.28-1.703 1.198-1.743 2.306v9.178l-1.11-.537C6.18 19.098 4.96 18 4.1 16.614M22.97 24.09l-6.256-3.874c-.102-.063-.218-.098-.33-.144 2.683-1.8 4.354-4.855 4.354-8.243 0-.486-.037-.964-.104-1.43a9.97 9.97 0 0 0-1.57-4.128l-.295-.408-.066-.092a10.05 10.05 0 0 0-.949-1.078c-.342-.334-.708-.643-1.094-.922-1.155-.834-2.492-1.412-3.94-1.65l-.732-.088-.748-.03a9.29 9.29 0 0 0-1.482.119c-1.447.238-2.786.816-3.94 1.65a9.33 9.33 0 0 0-.813.686 9.59 9.59 0 0 0-.845.877l-.385.437-.36.5-.288.468-.418.778-.04.09c-.593 1.28-.93 2.71-.93 4.222 0 3.832 2.182 7.342 5.56 8.938l1.437.68v4.946L5 25.64a4.44 4.44 0 0 0-.888-.086c-.017 0-.034.003-.05.003-.252.004-.503.033-.75.08a5.08 5.08 0 0 0-.237.056c-.193.046-.382.107-.568.18-.075.03-.15.057-.225.1-.25.114-.494.244-.723.405a1.31 1.31 0 0 0-.566 1.122 1.28 1.28 0 0 0 .645 1.051C4 29.925 5.96 31.614 7.473 33.563a5.06 5.06 0 0 0 .434.491c1.086 1.082 2.656 1.713 4.326 1.715h6.697c.748-.001 1.43-.333 1.858-.872.142-.18.256-.38.336-.602l2.757-7.74c.094-.26.13-.53.112-.794s-.088-.52-.203-.76a2.19 2.19 0 0 0-.821-.91" fill-opacity=".6" fill="#000" />
            <path d="M22.444 24.94l-6.257-3.874a1.45 1.45 0 0 0-.757-.211h-2.953v-9.88c0-.663-.616-1.203-1.373-1.203s-1.37.54-1.37 1.203v16.643l-4.922-.994a3.44 3.44 0 0 0-.692-.069 3.35 3.35 0 0 0-1.925.598c-.147.102-.198.198-.194.298.004.094.058.176.153.23 2.462 1.448 4.517 3.22 6.11 5.27.887 1.14 2.373 1.82 3.98 1.82h6.686c.577 0 1.08-.326 1.253-.8l2.76-7.74c.16-.448-.017-.923-.426-1.22-.025-.02-.043-.043-.07-.06z" fill="#fff" />
            <g transform="translate(0 .769)">
                <mask id="B" fill="#fff">
                    <use xlink:href="#A" />
                </mask>
                <path d="M23.993 24.992a1.96 1.96 0 0 1-.111.794l-2.758 7.74c-.08.22-.194.423-.336.602-.427.54-1.11.87-1.857.872h-6.698c-1.67-.002-3.24-.633-4.326-1.715-.154-.154-.3-.318-.434-.49C5.96 30.846 4 29.157 1.646 27.773c-.385-.225-.626-.618-.645-1.05a1.31 1.31 0 0 1 .566-1.122 4.56 4.56 0 0 1 .723-.405l.225-.1a4.3 4.3 0 0 1 .568-.18l.237-.056c.248-.046.5-.075.75-.08.018 0 .034-.003.05-.003.303-.001.597.027.89.086l3.722.752V20.68l-1.436-.68c-3.377-1.596-5.56-5.106-5.56-8.938 0-1.51.336-2.94.93-4.222.015-.03.025-.06.04-.09.127-.267.268-.525.418-.778.093-.16.186-.316.288-.468.063-.095.133-.186.2-.277L3.773 5c.118-.155.26-.29.385-.437.266-.3.544-.604.845-.877a9.33 9.33 0 0 1 .813-.686C6.97 2.167 8.31 1.59 9.757 1.35a9.27 9.27 0 0 1 1.481-.119 8.82 8.82 0 0 1 .748.031c.247.02.49.05.733.088 1.448.238 2.786.816 3.94 1.65.387.28.752.588 1.094.922a9.94 9.94 0 0 1 .949 1.078l.066.092c.102.133.203.268.295.408a9.97 9.97 0 0 1 1.571 4.128c.066.467.103.945.103 1.43 0 3.388-1.67 6.453-4.353 8.243.11.046.227.08.33.144l6.256 3.874c.37.23.645.55.82.9.115.24.185.498.203.76m.697-1.195c-.265-.55-.677-1.007-1.194-1.326l-5.323-3.297c2.255-2.037 3.564-4.97 3.564-8.114 0-2.19-.637-4.304-1.84-6.114-.126-.188-.26-.37-.4-.552-.645-.848-1.402-1.6-2.252-2.204C15.472.91 13.393.232 11.238.232A10.21 10.21 0 0 0 5.23 2.19c-.848.614-1.606 1.356-2.253 2.205-.136.18-.272.363-.398.55C1.374 6.756.737 8.87.737 11.06c0 4.218 2.407 8.08 6.133 9.842l.863.41v3.092l-2.525-.51c-.356-.07-.717-.106-1.076-.106a5.45 5.45 0 0 0-3.14.996c-.653.46-1.022 1.202-.99 1.983a2.28 2.28 0 0 0 1.138 1.872c2.24 1.318 4.106 2.923 5.543 4.772 1.26 1.62 3.333 2.59 5.55 2.592h6.698c1.42-.001 2.68-.86 3.134-2.138l2.76-7.74c.272-.757.224-1.584-.134-2.325" fill-opacity=".05" fill="#000" mask="url(#B)" />
            </g>
        </g>
    </g>
</svg>`
/* @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.
 */}
      </slot>
    </div>
  </div>

  <div id="finger0" class="animated-container cover">
    <slot name="finger0" aria-hidden="true">
    </slot>
  </div>
  <div id="finger1" class="animated-container cover">
    <slot name="finger1" aria-hidden="true">
    </slot>
  </div>

  <div class="slot default">
    <slot></slot>

    <div class="slot progress-bar">
      <slot name="progress-bar">
        <div id="default-progress-bar" aria-hidden="true">
          <div class="bar" part="default-progress-bar"></div>
        </div>
      </slot>
    </div>

    <div class="slot exit-webxr-ar-button">
      <slot name="exit-webxr-ar-button">
        <a id="default-exit-webxr-ar-button" part="default-exit-webxr-ar-button"
            tabindex="3"
            aria-label="Exit AR"
            aria-hidden="true">
          ${Jr`
<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" fill="#000000">
    <!-- NOTE(cdata): This SVG filter is a stop-gap until we can implement
         support for dynamic re-coloring of UI components -->
    <defs>
      <filter id="drop-shadow" x="-100%" y="-100%" width="300%" height="300%">
        <feGaussianBlur in="SourceAlpha" stdDeviation="1"/>
        <feOffset dx="0" dy="0" result="offsetblur"/>
        <feFlood flood-color="#000000"/>
        <feComposite in2="offsetblur" operator="in"/>
        <feMerge>
          <feMergeNode/>
          <feMergeNode in="SourceGraphic"/>
        </feMerge>
      </filter>
    </defs>
    <path filter="url(#drop-shadow)" d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
    <path d="M0 0h24v24H0z" fill="none"/>
</svg>`
/* @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.
 */}
        </a>
      </slot>
    </div>
  </div>
</div>
<div class="screen-reader-only" role="region" aria-label="Live announcements">
  <span id="status" role="status"></span>
</div>`,ks=new WeakMap;function DRACOWorker(){let e,t;function decodeAttribute(e,t,i,n,r,a){const o=a.num_components(),l=i.num_points()*o,c=l*r.BYTES_PER_ELEMENT,h=function getDracoDataType(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),d=e._malloc(c);t.GetAttributeDataArrayForAllPoints(i,a,h,c,d);const A=new r(e.HEAPF32.buffer,d,l).slice();return e._free(d),{name:n,array:A,itemSize:o}}onmessage=function(i){const n=i.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=n.buffer,r=n.taskConfig;t.then((e=>{const t=e.draco,a=new t.Decoder;try{const e=function decodeGeometry(e,t,i,n){const r=n.attributeIDs,a=n.attributeTypes;let o,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(i,i.byteLength,o);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(i,i.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 i in r){const l=self[a[i]];let c,d;if(n.useUniqueIDs)d=r[i],c=t.GetAttributeByUniqueId(o,d);else{if(d=t.GetAttributeId(o,e[r[i]]),-1===d)continue;c=t.GetAttribute(o,d)}const A=decodeAttribute(e,t,o,i,l,c);"color"===i&&(A.vertexColorSpace=n.vertexColorSpace),h.attributes.push(A)}c===e.TRIANGULAR_MESH&&(h.index=function decodeIndex(e,t,i){const n=i.num_faces(),r=3*n,a=4*r,o=e._malloc(a);t.GetTrianglesUInt32Array(i,a,o);const l=new Uint32Array(e.HEAPF32.buffer,o,r).slice();return e._free(o),{array:l,itemSize:1}}(e,t,o));return e.destroy(o),h}(t,a,new Int8Array(i),r),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(a)}}))}}}function toTrianglesDrawMode(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let i=e.getIndex();if(null===i){const t=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const n=i.count-2,r=[];if(2===t)for(let e=1;e<=n;e++)r.push(i.getX(0)),r.push(i.getX(e)),r.push(i.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(r.push(i.getX(e)),r.push(i.getX(e+1)),r.push(i.getX(e+2))):(r.push(i.getX(e+2)),r.push(i.getX(e+1)),r.push(i.getX(e)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=e.clone();return a.setIndex(r),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class GLTFLoader extends Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new GLTFMaterialsClearcoatExtension$1(e)})),this.register((function(e){return new GLTFTextureBasisUExtension(e)})),this.register((function(e){return new GLTFTextureWebPExtension(e)})),this.register((function(e){return new GLTFTextureAVIFExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension$1(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension$1(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension$1(e)})),this.register((function(e){return new GLTFMaterialsIorExtension$1(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension$1(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension$1(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension$1(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension$1(e)})),this.register((function(e){return new GLTFLightsExtension(e)})),this.register((function(e){return new GLTFMeshoptCompression(e)})),this.register((function(e){return new GLTFMeshGpuInstancing(e)}))}load(e,t,i,n){const r=this;let a;a=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const _onError=function(t){n?n(t):console.error(t),r.manager.itemError(e),r.manager.itemEnd(e)},o=new FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(i){try{r.parse(i,a,(function(i){t(i),r.manager.itemEnd(e)}),_onError)}catch(e){_onError(e)}}),i,_onError)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,n){let r;const a={},o={},l=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(l.decode(new Uint8Array(e,0,4))===Vs){try{a[Gs.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(e){return void(n&&n(e))}r=JSON.parse(a[Gs.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new GLTFParser(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](c);o[t.name]=t,a[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],i=r.extensionsRequired||[];switch(t){case Gs.KHR_MATERIALS_UNLIT:a[t]=new GLTFMaterialsUnlitExtension$1;break;case Gs.KHR_DRACO_MESH_COMPRESSION:a[t]=new GLTFDracoMeshCompressionExtension(r,this.dracoLoader);break;case Gs.KHR_TEXTURE_TRANSFORM:a[t]=new GLTFTextureTransformExtension;break;case Gs.KHR_MESH_QUANTIZATION:a[t]=new GLTFMeshQuantizationExtension;break;default:i.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(i,n)}parseAsync(e,t){const i=this;return new Promise((function(n,r){i.parse(e,t,n,r)}))}}function GLTFRegistry(){let e={};return{get:function(t){return e[t]},add:function(t,i){e[t]=i},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Gs={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 GLTFLightsExtension{constructor(e){this.parser=e,this.name=Gs.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let o;const l=new Color(16777215);void 0!==a.color&&l.fromArray(a.color);const c=void 0!==a.range?a.range:0;switch(a.type){case"directional":o=new DirectionalLight(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new PointLight(l),o.distance=c;break;case"spot":o=new SpotLight(l),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=void 0!==a.spot.innerConeAngle?a.spot.innerConeAngle:0,a.spot.outerConeAngle=void 0!==a.spot.outerConeAngle?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),o.decay=2,assignExtrasToUserData(o,a),void 0!==a.intensity&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(o),t.cache.add(i,n),n}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,n=i.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return i._getNodeRef(t.cache,r,e)}))}}class GLTFMaterialsUnlitExtension$1{constructor(){this.name=Gs.KHR_MATERIALS_UNLIT}getMaterialType(){return MeshBasicMaterial}extendParams(e,t,i){const n=[];e.color=new Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==r.baseColorTexture&&n.push(i.assignTexture(e,"map",r.baseColorTexture,be))}return Promise.all(n)}}class GLTFMaterialsEmissiveStrengthExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class GLTFMaterialsClearcoatExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];if(void 0!==a.clearcoatFactor&&(t.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&r.push(i.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&r.push(i.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(r.push(i.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){const e=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Vector2(e,e)}return Promise.all(r)}}class GLTFMaterialsIridescenceExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];return void 0!==a.iridescenceFactor&&(t.iridescence=a.iridescenceFactor),void 0!==a.iridescenceTexture&&r.push(i.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),void 0!==a.iridescenceIor&&(t.iridescenceIOR=a.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==a.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),void 0!==a.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),void 0!==a.iridescenceThicknessTexture&&r.push(i.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}}class GLTFMaterialsSheenExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=n.extensions[this.name];return void 0!==a.sheenColorFactor&&t.sheenColor.fromArray(a.sheenColorFactor),void 0!==a.sheenRoughnessFactor&&(t.sheenRoughness=a.sheenRoughnessFactor),void 0!==a.sheenColorTexture&&r.push(i.assignTexture(t,"sheenColorMap",a.sheenColorTexture,be)),void 0!==a.sheenRoughnessTexture&&r.push(i.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}}class GLTFMaterialsTransmissionExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];return void 0!==a.transmissionFactor&&(t.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&r.push(i.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}}class GLTFMaterialsVolumeExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];t.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&r.push(i.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const o=a.attenuationColor||[1,1,1];return t.attenuationColor=new Color(o[0],o[1],o[2]),Promise.all(r)}}class GLTFMaterialsIorExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=i.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];t.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&r.push(i.assignTexture(t,"specularIntensityMap",a.specularTexture));const o=a.specularColorFactor||[1,1,1];return t.specularColor=new Color(o[0],o[1],o[2]),void 0!==a.specularColorTexture&&r.push(i.assignTexture(t,"specularColorMap",a.specularColorTexture,be)),Promise.all(r)}}class GLTFMaterialsAnisotropyExtension$1{constructor(e){this.parser=e,this.name=Gs.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?MeshPhysicalMaterial:null}extendMaterialParams(e,t){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],a=n.extensions[this.name];return void 0!==a.anisotropyStrength&&(t.anisotropy=a.anisotropyStrength),void 0!==a.anisotropyRotation&&(t.anisotropyRotation=a.anisotropyRotation),void 0!==a.anisotropyTexture&&r.push(i.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=Gs.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=Gs.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const e=i.options.manager.getHandler(o.uri);null!==e&&(l=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,a.source,l);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=Gs.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const e=i.options.manager.getHandler(o.uri);null!==e&&(l=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,a.source,l);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=Gs.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const e=i.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then((function(t){const i=e.byteOffset||0,n=e.byteLength||0,a=e.count,o=e.byteStride,l=new Uint8Array(t,i,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,o,l,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(a*o);return r.decodeGltfBuffer(new Uint8Array(t),a,o,l,e.mode,e.filter),t}))}))}return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=Gs.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;const n=t.meshes[i.mesh];for(const e of n.primitives)if(e.mode!==qs.TRIANGLES&&e.mode!==qs.TRIANGLE_STRIP&&e.mode!==qs.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=i.extensions[this.name].attributes,a=[],o={};for(const e in r)a.push(this.parser.getDependency("accessor",r[e]).then((t=>(o[e]=t,o[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const t=e.pop(),i=t.isGroup?t.children:[t],n=e[0].count,r=[];for(const e of i){const t=new Matrix4,i=new Vector3,a=new Quaternion,l=new Vector3(1,1,1),c=new InstancedMesh(e.geometry,e.material,n);for(let e=0;e<n;e++)o.TRANSLATION&&i.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&l.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(i,a,l));for(const t in o)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);Object3D.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),r.push(c)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}}const Vs="glTF",Hs=1313821514,zs=5130562;class GLTFBinaryExtension{constructor(e){this.name=Gs.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Vs)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let a=0;for(;a<n;){const t=r.getUint32(a,!0);a+=4;const n=r.getUint32(a,!0);if(a+=4,n===Hs){const n=new Uint8Array(e,12+a,t);this.content=i.decode(n)}else if(n===zs){const i=12+a;this.body=e.slice(i,i+t)}a+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Gs.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const e in a){const t=$s[e]||e.toLowerCase();o[t]=a[e]}for(const t in e.attributes){const n=$s[t]||t.toLowerCase();if(void 0!==a[t]){const r=i.accessors[e.attributes[t]],a=Xs[r.componentType];c[n]=a.name,l[n]=!0===r.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){n.decodeDracoFile(e,(function(e){for(const t in e.attributes){const i=e.attributes[t],n=l[t];void 0!==n&&(i.normalized=n)}t(e)}),o,c)}))}))}}class GLTFTextureTransformExtension{constructor(){this.name=Gs.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class GLTFMeshQuantizationExtension{constructor(){this.name=Gs.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends Interpolant{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=i[r+e];return t}interpolate_(e,t,i,n){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=2*o,c=3*o,h=n-t,d=(i-t)/h,A=d*d,p=A*d,m=e*c,g=m-c,f=-2*p+3*A,v=p-A,E=1-f,y=v-A+d;for(let e=0;e!==o;e++){const t=a[g+e+o],i=a[g+e+l]*h,n=a[m+e+o],c=a[m+e]*h;r[e]=E*t+y*i+f*n+v*c}return r}}const Ws=new Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,t,i,n){const r=super.interpolate_(e,t,i,n);return Ws.fromArray(r).normalize().toArray(r),r}}const qs={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Xs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},js={9728:B,9729:O,9984:U,9985:G,9986:F,9987:W},Ys={33071:I,33648:T,10497:b},Ks={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$s={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Js={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Zs={CUBICSPLINE:void 0,LINEAR:ve,STEP:fe},ea="OPAQUE",ta="MASK",ia="BLEND";function createDefaultMaterial(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function addUnknownExtensionsToUserData(e,t,i){for(const n in i.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=i.extensions[n])}function assignExtrasToUserData(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function updateMorphTargets(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let i=0,n=t.weights.length;i<n;i++)e.morphTargetInfluences[i]=t.weights[i];if(t.extras&&Array.isArray(t.extras.targetNames)){const i=t.extras.targetNames;if(e.morphTargetInfluences.length===i.length){e.morphTargetDictionary={};for(let t=0,n=i.length;t<n;t++)e.morphTargetDictionary[i[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(e){let t;const i=e.extensions&&e.extensions[Gs.KHR_DRACO_MESH_COMPRESSION];if(t=i?"draco:"+i.bufferView+":"+i.indices+":"+createAttributesKey(i.attributes):e.indices+":"+createAttributesKey(e.attributes)+":"+e.mode,void 0!==e.targets)for(let i=0,n=e.targets.length;i<n;i++)t+=":"+createAttributesKey(e.targets[i]);return t}function createAttributesKey(e){let t="";const i=Object.keys(e).sort();for(let n=0,r=i.length;n<r;n++)t+=i[n]+":"+e[i[n]]+";";return t}function getNormalizedComponentScale(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const na=new Matrix4;class GLTFParser{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let i=!1,n=!1,r=-1;"undefined"!=typeof navigator&&(i=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||i||n&&r<98?this.textureLoader=new TextureLoader(this.options.manager):this.textureLoader=new ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(t){const a={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:i,userData:{}};addUnknownExtensionsToUserData(r,a,n),assignExtrasToUserData(a,n),Promise.all(i._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){e(a)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let i=0,n=t.length;i<n;i++){const n=t[i].joints;for(let t=0,i=n.length;t<i;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(i[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,i){if(e.refs[t]<=1)return i;const n=i.clone(),updateMappings=(e,t)=>{const i=this.associations.get(e);null!=i&&this.associations.set(t,i);for(const[i,n]of e.children.entries())updateMappings(n,t.children[i])};return updateMappings(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&i.push(r)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne((function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map((function(t,n){return i.getDependency(e,n)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Gs.KHR_BINARY_GLTF].body);const n=this.options;return new Promise((function(e,r){i.load(LoaderUtils.resolveURL(t.uri,n.path),e,void 0,(function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const i=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+i)}))}loadAccessor(e){const t=this,i=this.json,n=this.json.accessors[e];if(void 0===n.bufferView&&void 0===n.sparse){const e=Ks[n.type],t=Xs[n.componentType],i=!0===n.normalized,r=new t(n.count*e);return Promise.resolve(new BufferAttribute(r,e,i))}const r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(e){const r=e[0],a=Ks[n.type],o=Xs[n.componentType],l=o.BYTES_PER_ELEMENT,c=l*a,h=n.byteOffset||0,d=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,A=!0===n.normalized;let p,m;if(d&&d!==c){const e=Math.floor(h/d),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+e+":"+n.count;let c=t.cache.get(i);c||(p=new o(r,e*d,n.count*d/l),c=new InterleavedBuffer(p,d/l),t.cache.add(i,c)),m=new InterleavedBufferAttribute(c,a,h%d/l,A)}else p=null===r?new o(n.count*a):new o(r,h,n.count*a),m=new BufferAttribute(p,a,A);if(void 0!==n.sparse){const t=Ks.SCALAR,i=Xs[n.sparse.indices.componentType],l=n.sparse.indices.byteOffset||0,c=n.sparse.values.byteOffset||0,h=new i(e[1],l,n.sparse.count*t),d=new o(e[2],c,n.sparse.count*a);null!==r&&(m=new BufferAttribute(m.array.slice(),m.itemSize,m.normalized));for(let e=0,t=h.length;e<t;e++){const t=h[e];if(m.setX(t,d[e*a]),a>=2&&m.setY(t,d[e*a+1]),a>=3&&m.setZ(t,d[e*a+2]),a>=4&&m.setW(t,d[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m}))}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e].source,r=t.images[n];let a=this.textureLoader;if(r.uri){const e=i.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,i){const n=this,r=this.json,a=r.textures[e],o=r.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then((function(t){t.flipY=!1,t.name=a.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const i=(r.samplers||{})[a.sampler]||{};return t.magFilter=js[i.magFilter]||O,t.minFilter=js[i.minFilter]||W,t.wrapS=Ys[i.wrapS]||b,t.wrapT=Ys[i.wrapT]||b,n.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const a=n.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(void 0!==a.bufferView)l=i.getDependency("bufferView",a.bufferView).then((function(e){c=!0;const t=new Blob([e],{type:a.mimeType});return l=o.createObjectURL(t),l}));else if(void 0===a.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then((function(e){return new Promise((function(i,n){let a=i;!0===t.isImageBitmapLoader&&(a=function(e){const t=new Texture$1(e);t.needsUpdate=!0,i(t)}),t.load(LoaderUtils.resolveURL(e,r.path),a,void 0,n)}))})).then((function(e){return!0===c&&o.revokeObjectURL(l),e.userData.mimeType=a.mimeType||function getImageURIMimeType(e){return e.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"}(a.uri),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),e}));return this.sourceCache[e]=h,h}assignTexture(e,t,i,n){const r=this;return this.getDependency("texture",i.index).then((function(a){if(!a)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((a=a.clone()).channel=i.texCoord),r.extensions[Gs.KHR_TEXTURE_TRANSFORM]){const e=void 0!==i.extensions?i.extensions[Gs.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(a);a=r.extensions[Gs.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==n&&(a.colorSpace=n),e[t]=a,a}))}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Material$1.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,t.sizeAttenuation=!1,this.cache.add(e,t)),i=t}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Material$1.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,this.cache.add(e,t)),i=t}if(n||r||a){let e="ClonedMaterial:"+i.uuid+":";n&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}e.material=i}getMaterialType(){return MeshStandardMaterial}loadMaterial(e){const t=this,i=this.json,n=this.extensions,r=i.materials[e];let a;const o={},l=[];if((r.extensions||{})[Gs.KHR_MATERIALS_UNLIT]){const e=n[Gs.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(o,r,t))}else{const i=r.pbrMetallicRoughness||{};if(o.color=new Color(1,1,1),o.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;o.color.fromArray(e),o.opacity=e[3]}void 0!==i.baseColorTexture&&l.push(t.assignTexture(o,"map",i.baseColorTexture,be)),o.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,o.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",i.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",i.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===r.doubleSided&&(o.side=2);const c=r.alphaMode||ea;if(c===ia?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===ta&&(o.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&a!==MeshBasicMaterial&&(l.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Vector2(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;o.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&a!==MeshBasicMaterial&&(l.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(o.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&a!==MeshBasicMaterial&&(o.emissive=(new Color).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&a!==MeshBasicMaterial&&l.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,be)),Promise.all(l).then((function(){const i=new a(o);return r.name&&(i.name=r.name),assignExtrasToUserData(i,r),t.associations.set(i,{materials:e}),r.extensions&&addUnknownExtensionsToUserData(n,i,r),i}))}createUniqueName(e){const t=PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function createDracoPrimitive(e){return i[Gs.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(i){return addPrimitiveAttributes(i,e,t)}))}const r=[];for(let i=0,a=e.length;i<a;i++){const a=e[i],o=createPrimitiveKey(a),l=n[o];if(l)r.push(l.promise);else{let e;e=a.extensions&&a.extensions[Gs.KHR_DRACO_MESH_COMPRESSION]?createDracoPrimitive(a):addPrimitiveAttributes(new BufferGeometry,a,t),n[o]={primitive:a,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,i=this.json,n=this.extensions,r=i.meshes[e],a=r.primitives,o=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?createDefaultMaterial(this.cache):this.getDependency("material",a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then((function(i){const o=i.slice(0,i.length-1),l=i[i.length-1],c=[];for(let i=0,h=l.length;i<h;i++){const h=l[i],d=a[i];let A;const p=o[i];if(d.mode===qs.TRIANGLES||d.mode===qs.TRIANGLE_STRIP||d.mode===qs.TRIANGLE_FAN||void 0===d.mode)A=!0===r.isSkinnedMesh?new SkinnedMesh(h,p):new Mesh(h,p),!0===A.isSkinnedMesh&&A.normalizeSkinWeights(),d.mode===qs.TRIANGLE_STRIP?A.geometry=toTrianglesDrawMode(A.geometry,1):d.mode===qs.TRIANGLE_FAN&&(A.geometry=toTrianglesDrawMode(A.geometry,2));else if(d.mode===qs.LINES)A=new LineSegments(h,p);else if(d.mode===qs.LINE_STRIP)A=new Line(h,p);else if(d.mode===qs.LINE_LOOP)A=new LineLoop(h,p);else{if(d.mode!==qs.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);A=new Points(h,p)}Object.keys(A.geometry.morphAttributes).length>0&&updateMorphTargets(A,r),A.name=t.createUniqueName(r.name||"mesh_"+e),assignExtrasToUserData(A,r),d.extensions&&addUnknownExtensionsToUserData(n,A,d),t.assignFinalMaterial(A),c.push(A)}for(let i=0,n=c.length;i<n;i++)t.associations.set(c[i],{meshes:e,primitives:i});if(1===c.length)return r.extensions&&addUnknownExtensionsToUserData(n,c[0],r),c[0];const h=new Group;r.extensions&&addUnknownExtensionsToUserData(n,h,r),t.associations.set(h,{meshes:e});for(let e=0,t=c.length;e<t;e++)h.add(c[e]);return h}))}loadCamera(e){let t;const i=this.json.cameras[e],n=i[i.type];if(n)return"perspective"===i.type?t=new PerspectiveCamera(Xe.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(t=new OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),assignExtrasToUserData(t,i),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],i=[];for(let e=0,n=t.joints.length;e<n;e++)i.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then((function(e){const i=e.pop(),n=e,r=[],a=[];for(let e=0,o=n.length;e<o;e++){const o=n[e];if(o){r.push(o);const t=new Matrix4;null!==i&&t.fromArray(i.array,16*e),a.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new Skeleton(r,a)}))}loadAnimation(e){const t=this.json,i=this,n=t.animations[e],r=n.name?n.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let e=0,t=n.channels.length;e<t;e++){const t=n.channels[e],i=n.samplers[t.sampler],r=t.target,d=r.node,A=void 0!==n.parameters?n.parameters[i.input]:i.input,p=void 0!==n.parameters?n.parameters[i.output]:i.output;void 0!==r.node&&(a.push(this.getDependency("node",d)),o.push(this.getDependency("accessor",A)),l.push(this.getDependency("accessor",p)),c.push(i),h.push(r))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then((function(e){const t=e[0],n=e[1],a=e[2],o=e[3],l=e[4],c=[];for(let e=0,r=t.length;e<r;e++){const r=t[e],h=n[e],d=a[e],A=o[e],p=l[e];if(void 0===r)continue;r.updateMatrix&&(r.updateMatrix(),r.matrixAutoUpdate=!0);const m=i._createAnimationTracks(r,h,d,A,p);if(m)for(let e=0;e<m.length;e++)c.push(m[e])}return new AnimationClip(r,void 0,c)}))}createNodeMesh(e){const t=this.json,i=this,n=t.nodes[e];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then((function(e){const t=i._getNodeRef(i.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,i=n.weights.length;t<i;t++)e.morphTargetInfluences[t]=n.weights[t]})),t}))}loadNode(e){const t=this,i=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],a=i.children||[];for(let e=0,i=a.length;e<i;e++)r.push(t.getDependency("node",a[e]));const o=void 0===i.skin?Promise.resolve(null):t.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),o]).then((function(e){const t=e[0],i=e[1],n=e[2];null!==n&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(n,na)}));for(let e=0,n=i.length;e<n;e++)t.add(i[e]);return t}))}_loadNodeShallow(e){const t=this.json,i=this.extensions,n=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const r=t.nodes[e],a=r.name?n.createUniqueName(r.name):"",o=[],l=n._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return l&&o.push(l),void 0!==r.camera&&o.push(n.getDependency("camera",r.camera).then((function(e){return n._getNodeRef(n.cameraCache,r.camera,e)}))),n._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){o.push(e)})),this.nodeCache[e]=Promise.all(o).then((function(t){let o;if(o=!0===r.isBone?new Bone:t.length>1?new Group:1===t.length?t[0]:new Object3D,o!==t[0])for(let e=0,i=t.length;e<i;e++)o.add(t[e]);if(r.name&&(o.userData.name=r.name,o.name=a),assignExtrasToUserData(o,r),r.extensions&&addUnknownExtensionsToUserData(i,o,r),void 0!==r.matrix){const e=new Matrix4;e.fromArray(r.matrix),o.applyMatrix4(e)}else void 0!==r.translation&&o.position.fromArray(r.translation),void 0!==r.rotation&&o.quaternion.fromArray(r.rotation),void 0!==r.scale&&o.scale.fromArray(r.scale);return n.associations.has(o)||n.associations.set(o,{}),n.associations.get(o).nodes=e,o})),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],n=this,r=new Group;i.name&&(r.name=n.createUniqueName(i.name)),assignExtrasToUserData(r,i),i.extensions&&addUnknownExtensionsToUserData(t,r,i);const a=i.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(n.getDependency("node",a[e]));return Promise.all(o).then((function(e){for(let t=0,i=e.length;t<i;t++)r.add(e[t]);return n.associations=(e=>{const t=new Map;for(const[e,i]of n.associations)(e instanceof Material$1||e instanceof Texture$1)&&t.set(e,i);return e.traverse((e=>{const i=n.associations.get(e);null!=i&&t.set(e,i)})),t})(r),r}))}_createAnimationTracks(e,t,i,n,r){const a=[],o=e.name?e.name:e.uuid,l=[];let c;switch(Js[r.path]===Js.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),Js[r.path]){case Js.weights:c=NumberKeyframeTrack;break;case Js.rotation:c=QuaternionKeyframeTrack;break;default:switch(i.itemSize){case 1:c=NumberKeyframeTrack;break;case 2:case 3:c=VectorKeyframeTrack}}const h=void 0!==n.interpolation?Zs[n.interpolation]:ve,d=this._getArrayFromAccessor(i);for(let e=0,i=l.length;e<i;e++){const i=new c(l[e]+"."+Js[r.path],t.array,d,h);"CUBICSPLINE"===h&&this._createCubicSplineTrackInterpolant(i),a.push(i)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=getNormalizedComponentScale(t.constructor),i=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=t[n]*e;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function InterpolantFactoryMethodGLTFCubicSpline(e){return new(this instanceof QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function addPrimitiveAttributes(e,t,i){const n=t.attributes,r=[];function assignAttributeAccessor(t,n){return i.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}for(const t in n){const i=$s[t]||t.toLowerCase();i in e.attributes||r.push(assignAttributeAccessor(n[t],i))}if(void 0!==t.indices&&!e.index){const n=i.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(n)}return assignExtrasToUserData(e,t),function computeBounds(e,t,i){const n=t.attributes,r=new Box3;if(void 0===n.POSITION)return;{const e=i.json.accessors[n.POSITION],t=e.min,a=e.max;if(void 0===t||void 0===a)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(r.set(new Vector3(t[0],t[1],t[2]),new Vector3(a[0],a[1],a[2])),e.normalized){const t=getNormalizedComponentScale(Xs[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}const a=t.targets;if(void 0!==a){const e=new Vector3,t=new Vector3;for(let n=0,r=a.length;n<r;n++){const r=a[n];if(void 0!==r.POSITION){const n=i.json.accessors[r.POSITION],a=n.min,o=n.max;if(void 0!==a&&void 0!==o){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),n.normalized){const e=getNormalizedComponentScale(Xs[n.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(e)}e.boundingBox=r;const o=new Sphere;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=o}(e,t,i),Promise.all(r).then((function(){return void 0!==t.targets?function addMorphTargets(e,t,i){let n=!1,r=!1,a=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e];if(void 0!==i.POSITION&&(n=!0),void 0!==i.NORMAL&&(r=!0),void 0!==i.COLOR_0&&(a=!0),n&&r&&a)break}if(!n&&!r&&!a)return Promise.resolve(e);const o=[],l=[],c=[];for(let h=0,d=t.length;h<d;h++){const d=t[h];if(n){const t=void 0!==d.POSITION?i.getDependency("accessor",d.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==d.NORMAL?i.getDependency("accessor",d.NORMAL):e.attributes.normal;l.push(t)}if(a){const t=void 0!==d.COLOR_0?i.getDependency("accessor",d.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(c)]).then((function(t){const i=t[0],o=t[1],l=t[2];return n&&(e.morphAttributes.position=i),r&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=l),e.morphTargetsRelative=!0,e}))}(e,t.targets,i):e}))}class WorkerPool{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const i=this.workersResolve[e];if(i&&i(t),this.queue.length){const{resolve:t,msg:i,transfer:n}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(i,n)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((i=>{const n=this._getIdleWorker();-1!==n?(this._initWorker(n),this.workerStatus|=1<<n,this.workersResolve[n]=i,this.workers[n].postMessage(e,t)):this.queue.push({resolve:i,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const ra=9,sa=15,aa=16,oa=22,la=37,ca=43,ha=76,ua=83,da=97,Aa=100,pa=103,ma=109;class Si{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 Ii{constructor(e,t,i,n){this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=n,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const i=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==t&&n<e;)n++,this._offset++;return n<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,n)}}const ga=[171,75,84,88,32,50,48,187,13,10,26,10];function Ei(e){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):Buffer.from(e).toString("utf8")}let fa,va,Ea;const ya={env:{emscripten_notify_memory_growth:function(e){Ea=new Uint8Array(va.exports.memory.buffer)}}};class Q{init(){return fa||(fa="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+_a).then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,ya))).then(this._init):WebAssembly.instantiate(Buffer.from(_a,"base64"),ya).then(this._init),fa)}_init(e){va=e.instance,ya.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!va)throw new Error("ZSTDDecoder: Await .init() before decoding.");const i=e.byteLength,n=va.exports.malloc(i);Ea.set(e,n),t=t||Number(va.exports.ZSTD_findDecompressedSize(n,i));const r=va.exports.malloc(t),a=va.exports.ZSTD_decompress(r,t,n,i),o=Ea.slice(r,r+a);return va.exports.free(n),va.exports.free(r),o}}const _a=" ",xa=new WeakMap;let Sa,Ca=0;class KTX2Loader extends Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new WorkerPool,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(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return!0===e.isWebGPURenderer?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new FileLoader(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),i=new FileLoader(this.manager);i.setPath(this.transcoderPath),i.setResponseType("arraybuffer"),i.setWithCredentials(this.withCredentials);const n=i.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,n]).then((([e,t])=>{const i=KTX2Loader.BasisWorker.toString(),n=["/* constants */","let _EngineFormat = "+JSON.stringify(KTX2Loader.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(KTX2Loader.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(KTX2Loader.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),Ca>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),Ca++}return this.transcoderPending}load(e,t,i,n){if(null===this.workerConfig)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new FileLoader(this.manager);r.setResponseType("arraybuffer"),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{if(xa.has(e)){return xa.get(e).promise.then(t).catch(n)}this._createTexture(e).then((e=>t?t(e):null)).catch(n)}),i,n)}_createTextureFrom(e,t){const{faces:i,width:n,height:r,format:a,type:o,error:l,dfdTransferFn:c,dfdFlags:h}=e;if("error"===o)return Promise.reject(l);let d;if(6===t.faceCount)d=new CompressedTexture,d.image=i,d.format=a,d.type=q;else{const e=i[0].mipmaps;d=t.layerCount>1?new CompressedArrayTexture(e,n,r,t.layerCount,a,q):new CompressedTexture(e,n,r,a,q)}return d.minFilter=1===i[0].mipmaps.length?O:W,d.magFilter=O,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=2===c?be:Me,d.premultiplyAlpha=!!(1&h),d}async _createTexture(e,t={}){const i=function Pi(e){const t=new Uint8Array(e.buffer,e.byteOffset,ga.length);if(t[0]!==ga[0]||t[1]!==ga[1]||t[2]!==ga[2]||t[3]!==ga[3]||t[4]!==ga[4]||t[5]!==ga[5]||t[6]!==ga[6]||t[7]!==ga[7]||t[8]!==ga[8]||t[9]!==ga[9]||t[10]!==ga[10]||t[11]!==ga[11])throw new Error("Missing KTX 2.0 identifier.");const i=new Si,n=17*Uint32Array.BYTES_PER_ELEMENT,r=new Ii(e,ga.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 a=r._nextUint32();i.supercompressionScheme=r._nextUint32();const o=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),h=r._nextUint32(),d=r._nextUint64(),A=r._nextUint64(),p=new Ii(e,ga.length+n,3*a*8,!0);for(let t=0;t<a;t++)i.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+p._nextUint64(),p._nextUint64()),uncompressedByteLength:p._nextUint64()});const m=new Ii(e,o,l,!0),g={vendorId:m._skip(4)._nextUint16(),descriptorType:m._nextUint16(),versionNumber:m._nextUint16(),descriptorBlockSize:m._nextUint16(),colorModel:m._nextUint8(),colorPrimaries:m._nextUint8(),transferFunction:m._nextUint8(),flags:m._nextUint8(),texelBlockDimension:[m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8()],bytesPlane:[m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8()],samples:[]},f=(g.descriptorBlockSize/4-6)/4;for(let e=0;e<f;e++){const t={bitOffset:m._nextUint16(),bitLength:m._nextUint8(),channelType:m._nextUint8(),samplePosition:[m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&t.channelType?(t.sampleLower=m._nextInt32(),t.sampleUpper=m._nextInt32()):(t.sampleLower=m._nextUint32(),t.sampleUpper=m._nextUint32()),g.samples[e]=t}i.dataFormatDescriptor.length=0,i.dataFormatDescriptor.push(g);const v=new Ii(e,c,h,!0);for(;v._offset<h;){const e=v._nextUint32(),t=v._scan(e),n=Ei(t),r=v._scan(e-t.byteLength);i.keyValue[n]=n.match(/^ktx/i)?Ei(r):r,v._offset%4&&v._skip(4-v._offset%4)}if(A<=0)return i;const E=new Ii(e,d,A,!0),y=E._nextUint16(),_=E._nextUint16(),x=E._nextUint32(),S=E._nextUint32(),C=E._nextUint32(),b=E._nextUint32(),I=[];for(let e=0;e<a;e++)I.push({imageFlags:E._nextUint32(),rgbSliceByteOffset:E._nextUint32(),rgbSliceByteLength:E._nextUint32(),alphaSliceByteOffset:E._nextUint32(),alphaSliceByteLength:E._nextUint32()});const T=d+E._offset,B=T+x,U=B+S,F=U+C,O=new Uint8Array(e.buffer,e.byteOffset+T,x),G=new Uint8Array(e.buffer,e.byteOffset+B,S),W=new Uint8Array(e.buffer,e.byteOffset+U,C),q=new Uint8Array(e.buffer,e.byteOffset+F,b);return i.globalData={endpointCount:y,selectorCount:_,imageDescs:I,endpointsData:O,selectorsData:G,tablesData:W,extendedData:q},i}(new Uint8Array(e));if(0!==i.vkFormat){const e=[],t=[];for(let n=0;n<i.levels.length;n++)t.push(createDataTexture(i,n).then((function(t){e[n]=t})));await Promise.all(t);const n=e[0];return n.mipmaps=e.map((e=>({data:e.source.data,width:e.source.data.width,height:e.source.data.height,depth:e.source.data.depth}))),n}const n=t,r=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:n},[e]))).then((e=>this._createTextureFrom(e.data,i)));return xa.set(e,{promise:r}),r}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),Ca--,this}}KTX2Loader.BasisFormat={ETC1S:0,UASTC_4x4:1},KTX2Loader.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},KTX2Loader.EngineFormat={RGBAFormat:ee,RGBA_ASTC_4x4_Format:Ae,RGBA_BPTC_Format:pe,RGBA_ETC2_EAC_Format:de,RGBA_PVRTC_4BPPV1_Format:he,RGBA_S3TC_DXT5_Format:le,RGB_ETC1_Format:36196,RGB_ETC2_Format:ue,RGB_PVRTC_4BPPV1_Format:ce,RGB_S3TC_DXT1_Format:se},KTX2Loader.BasisWorker=function(){let e,t,i;const n=_EngineFormat,r=_TranscoderFormat,a=_BasisFormat;self.addEventListener("message",(function(o){const h=o.data;switch(h.type){case"init":e=h.config,function init(e){t=new Promise((t=>{i={wasmBinary:e,onRuntimeInitialized:t},BASIS(i)})).then((()=>{i.initializeBasis(),void 0===i.KTX2File&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")}))}(h.transcoderBinary);break;case"transcode":t.then((()=>{try{const{faces:t,buffers:o,width:d,height:A,hasAlpha:p,format:m,dfdTransferFn:g,dfdFlags:f}=function transcode(t){const o=new i.KTX2File(new Uint8Array(t));function cleanup(){o.close(),o.delete()}if(!o.isValid())throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid or unsupported .ktx2 file");const h=o.isUASTC()?a.UASTC_4x4:a.ETC1S,d=o.getWidth(),A=o.getHeight(),p=o.getLayers()||1,m=o.getLevels(),g=o.getFaces(),f=o.getHasAlpha(),v=o.getDFDTransferFunc(),E=o.getDFDFlags(),{transcoderFormat:y,engineFormat:_}=function getTranscoderFormat(t,i,o,h){let d,A;const p=t===a.ETC1S?l:c;for(let n=0;n<p.length;n++){const r=p[n];if(e[r.if]&&(r.basisFormat.includes(t)&&!(h&&r.transcoderFormat.length<2)&&(!r.needsPowerOfTwo||isPowerOfTwo(i)&&isPowerOfTwo(o))))return d=r.transcoderFormat[h?1:0],A=r.engineFormat[h?1:0],{transcoderFormat:d,engineFormat:A}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),d=r.RGBA32,A=n.RGBAFormat,{transcoderFormat:d,engineFormat:A}}(h,d,A,f);if(!d||!A||!m)throw cleanup(),new Error("THREE.KTX2Loader:\tInvalid texture");if(!o.startTranscoding())throw cleanup(),new Error("THREE.KTX2Loader: .startTranscoding failed");const x=[],S=[];for(let e=0;e<g;e++){const t=[];for(let i=0;i<m;i++){const n=[];let r,a;for(let t=0;t<p;t++){const l=o.getImageLevelInfo(i,t,e);0!==e||0!==i||0!==t||l.origWidth%4==0&&l.origHeight%4==0||console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),m>1?(r=l.origWidth,a=l.origHeight):(r=l.width,a=l.height);const c=new Uint8Array(o.getImageTranscodedSizeInBytes(i,t,0,y));if(!o.transcodeImage(c,i,t,e,y,0,-1,-1))throw cleanup(),new Error("THREE.KTX2Loader: .transcodeImage failed.");n.push(c)}const l=concat(n);t.push({data:l,width:r,height:a}),S.push(l.buffer)}x.push({mipmaps:t,width:d,height:A,format:_})}return cleanup(),{faces:x,buffers:S,width:d,height:A,hasAlpha:f,format:_,dfdTransferFn:v,dfdFlags:E}}(h.buffer);self.postMessage({type:"transcode",id:h.id,faces:t,width:d,height:A,hasAlpha:p,format:m,dfdTransferFn:g,dfdFlags:f},o)}catch(e){console.error(e),self.postMessage({type:"error",id:h.id,error:e.message})}}))}}));const o=[{if:"astcSupported",basisFormat:[a.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:[a.ETC1S,a.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:[a.ETC1S,a.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:[a.ETC1S,a.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:[a.ETC1S,a.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[a.ETC1S,a.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}],l=o.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),c=o.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function isPowerOfTwo(e){return e<=2||!(e&e-1)&&0!==e}function concat(e){if(1===e.length)return e[0];let t=0;for(let i=0;i<e.length;i++){t+=e[i].byteLength}const i=new Uint8Array(t);let n=0;for(let t=0;t<e.length;t++){const r=e[t];i.set(r,n),n+=r.byteLength}return i}};const Ma={[ma]:ee,[da]:ee,[la]:ee,[ca]:ee,[pa]:re,[ua]:re,[aa]:re,[oa]:re,[Aa]:ne,[ha]:ne,[sa]:ne,[ra]:ne},ba={[ma]:K,[da]:$,[la]:q,[ca]:q,[pa]:K,[ua]:$,[aa]:q,[oa]:q,[Aa]:K,[ha]:$,[sa]:q,[ra]:q},Ia={[ca]:be,[oa]:be,[sa]:be};async function createDataTexture(e,t=0){const{vkFormat:i}=e,n=Math.max(1,e.pixelWidth>>t),r=Math.max(1,e.pixelHeight>>t),a=Math.max(1,e.pixelDepth>>t);if(void 0===Ma[i])throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const o=e.levels[t];let l,c;if(0===e.supercompressionScheme)l=o.levelData;else{if(2!==e.supercompressionScheme)throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");Sa||(Sa=new Promise((async e=>{const t=new Q;await t.init(),e(t)}))),l=(await Sa).decode(o.levelData,o.uncompressedByteLength)}c=ba[i]===K?new Float32Array(l.buffer,l.byteOffset,l.byteLength/Float32Array.BYTES_PER_ELEMENT):ba[i]===$?new Uint16Array(l.buffer,l.byteOffset,l.byteLength/Uint16Array.BYTES_PER_ELEMENT):l;const h=0===a?new DataTexture(c,n,r):new Data3DTexture(c,n,r,a);return h.type=ba[i],h.format=Ma[i],h.colorSpace=Ia[i]||Me,h.needsUpdate=!0,Promise.resolve(h)}
/* @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 wa,Ta;const Ba=Symbol("retainerCount"),Ra=Symbol("recentlyUsed"),La=Symbol("evict"),Da=Symbol("evictionThreshold"),Ua=Symbol("cache");class CacheEvictionPolicy{constructor(e,t=5){this[wa]=new Map,this[Ta]=[],this[Ua]=e,this[Da]=t}set evictionThreshold(e){this[Da]=e,this[La]()}get evictionThreshold(){return this[Da]}get cache(){return this[Ua]}retainerCount(e){return this[Ba].get(e)||0}reset(){this[Ba].clear(),this[Ra]=[]}retain(e){this[Ba].has(e)||this[Ba].set(e,0),this[Ba].set(e,this[Ba].get(e)+1);const t=this[Ra].indexOf(e);-1!==t&&this[Ra].splice(t,1),this[Ra].unshift(e),this[La]()}release(e){this[Ba].has(e)&&this[Ba].set(e,Math.max(this[Ba].get(e)-1,0)),this[La]()}[(wa=Ba,Ta=Ra,La)](){if(!(this[Ra].length<this[Da]))for(let e=this[Ra].length-1;e>=this[Da];--e){const t=this[Ra][e];0===this[Ba].get(t)&&(this[Ua].delete(t),this[Ra].splice(e,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 mappingsArrayToTable=e=>{const t=new Map;for(const i of e.mappings)for(const e of i.variants)t.set(e,{material:null,gltfMaterialIndex:i.material});return t};class GLTFMaterialsVariantsExtension{constructor(e){this.parser=e,this.name="KHR_materials_variants"}afterRoot(e){const t=this.parser,i=t.json;if(void 0===i.extensions||void 0===i.extensions[this.name])return null;const n=(e=>{const t=[],i=new Set;for(const n of e){let e=n,r=0;for(;i.has(e);)e=n+"."+ ++r;i.add(e),t.push(e)}return t})((i.extensions[this.name].variants||[]).map((e=>e.name)));for(const n of e.scenes)n.traverse((e=>{const n=e;if(!n.material)return;const r=t.associations.get(n);if(null==r||null==r.meshes||null==r.primitives)return;const a=i.meshes[r.meshes].primitives[r.primitives].extensions;a&&a[this.name]&&(n.userData.variantMaterials=mappingsArrayToTable(a[this.name]))}));return e.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 Pa,Fa;Texture$1.DEFAULT_ANISOTROPY=4;const Na=new Map,Qa=new Map;let Oa;const ka=new class DRACOLoader extends Loader{constructor(e){super(e),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(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,i,n){const r=new FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(e=>{this.parse(e,t,n)}),i,n)}parse(e,t,i){this.decodeDracoFile(e,t,null,null,be).catch(i)}decodeDracoFile(e,t,i,n,r=Ie){const a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){const i=JSON.stringify(t);if(ks.has(e)){const t=ks.get(e);if(t.key===i)return t.promise;if(0===e.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++,a=e.byteLength,o=this._getWorker(r,a).then((i=>(n=i,new Promise(((i,a)=>{n._callbacks[r]={resolve:i,reject:a},n.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{n&&r&&this._releaseTask(n,r)})),ks.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new BufferGeometry;e.index&&t.setIndex(new BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i],r=n.name,a=n.array,o=n.itemSize,l=new BufferAttribute(a,o);"color"===r&&(this._assignVertexColorSpace(l,n.vertexColorSpace),l.normalized=a instanceof Float32Array==!1),t.setAttribute(r,l)}return t}_assignVertexColorSpace(e,t){if(t!==be)return;const i=new Color;for(let t=0,n=e.count;t<n;t++)i.fromBufferAttribute(e,t).convertSRGBToLinear(),e.setXYZ(t,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise(((t,n)=>{i.load(e,t,void 0,n)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const i=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const n=DRACOWorker.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(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const i=t.data;switch(i.type){case"decode":e._callbacks[i.id].resolve(i);break;case"error":e._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}};let Ga;const Va=new KTX2Loader;let Ha,za;const Wa=Symbol("loader"),qa=Symbol("evictionPolicy"),Xa=Symbol("GLTFInstance");class CachingGLTFLoader extends EventDispatcher{constructor(e){super(),this[Fa]=(new GLTFLoader).register((e=>new GLTFMaterialsVariantsExtension(e))),this[Xa]=e,this[Wa].setDRACOLoader(ka),this[Wa].setKTX2Loader(Va)}static setDRACODecoderLocation(e){Oa=e,ka.setDecoderPath(e)}static getDRACODecoderLocation(){return Oa}static setKTX2TranscoderLocation(e){Ga=e,Va.setTranscoderPath(e)}static getKTX2TranscoderLocation(){return Ga}static setMeshoptDecoderLocation(e){var t;Ha!==e&&(Ha=e,za=(t=e,new Promise(((e,i)=>{const n=document.createElement("script");document.body.appendChild(n),n.onload=e,n.onerror=i,n.async=!0,n.src=t}))).then((()=>MeshoptDecoder.ready)).then((()=>MeshoptDecoder)))}static getMeshoptDecoderLocation(){return Ha}static initializeKTX2Loader(e){Va.detectSupport(e)}static get cache(){return Na}static clearCache(){Na.forEach(((e,t)=>{this.delete(t)})),this[qa].reset()}static has(e){return Na.has(e)}static async delete(e){if(!this.has(e))return;const t=Na.get(e);Qa.delete(e),Na.delete(e);(await t).dispose()}static hasFinishedLoading(e){return!!Qa.get(e)}get[(Pa=qa,Fa=Wa,qa)](){return this.constructor[qa]}async preload(e,t,i=()=>{}){if(this[Wa].setWithCredentials(CachingGLTFLoader.withCredentials),this.dispatchEvent({type:"preload",element:t,src:e}),!Na.has(e)){null!=za&&this[Wa].setMeshoptDecoder(await za);const t=((e,t,i=()=>{})=>{const onProgress=e=>{const t=e.loaded/e.total;i(Math.max(0,Math.min(1,isFinite(t)?t:1)))};return new Promise(((i,n)=>{t.load(e,i,onProgress,n)}))})(e,this[Wa],(e=>{i(.8*e)})),n=this[Xa],r=t.then((e=>n.prepare(e))).then((e=>(i(.9),new n(e)))).catch((e=>(console.error(e),new n)));Na.set(e,r)}await Na.get(e),Qa.set(e,!0),i&&i(1)}async load(e,t,i=()=>{}){await this.preload(e,t,i);const n=await Na.get(e),r=await n.clone();return this[qa].retain(e),r.dispose=()=>{this[qa].release(e)},r}}CachingGLTFLoader[Pa]=new CacheEvictionPolicy(CachingGLTFLoader);class CSS2DObject extends Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new Vector2(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const ja=new Vector3,Ya=new Matrix4,Ka=new Matrix4,$a=new Vector3,Ja=new Vector3;class CSS2DRenderer{constructor(e={}){const t=this;let i,n,r,a;const o={objects:new WeakMap},l=void 0!==e.element?e.element:document.createElement("div");function renderObject(e,i,n){if(e.isCSS2DObject){ja.setFromMatrixPosition(e.matrixWorld),ja.applyMatrix4(Ka);const c=!0===e.visible&&ja.z>=-1&&ja.z<=1&&!0===e.layers.test(n.layers);if(e.element.style.display=!0===c?"":"none",!0===c){e.onBeforeRender(t,i,n);const o=e.element;o.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(ja.x*r+r)+"px,"+(-ja.y*a+a)+"px)",o.parentNode!==l&&l.appendChild(o),e.onAfterRender(t,i,n)}const h={distanceToCameraSquared:getDistanceToSquared(n,e)};o.objects.set(e,h)}for(let t=0,r=e.children.length;t<r;t++)renderObject(e.children[t],i,n)}function getDistanceToSquared(e,t){return $a.setFromMatrixPosition(e.matrixWorld),Ja.setFromMatrixPosition(t.matrixWorld),$a.distanceToSquared(Ja)}l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:i,height:n}},this.render=function(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),Ya.copy(t.matrixWorldInverse),Ka.multiplyMatrices(t.projectionMatrix,Ya),renderObject(e,e,t),function zOrder(e){const t=function filterAndFlatten(e){const t=[];return e.traverse((function(e){e.isCSS2DObject&&t.push(e)})),t}(e).sort((function(e,t){if(e.renderOrder!==t.renderOrder)return t.renderOrder-e.renderOrder;return o.objects.get(e).distanceToCameraSquared-o.objects.get(t).distanceToCameraSquared})),i=t.length;for(let e=0,n=t.length;e<n;e++)t[e].element.style.zIndex=i-e}(e)},this.setSize=function(e,t){i=e,n=t,r=i/2,a=n/2,l.style.width=e+"px",l.style.height=t+"px"}}}function reduceVertices(e,t,i){let n=i;const r=new Vector3;return e.updateWorldMatrix(!0,!0),e.traverseVisible((e=>{const{geometry:i}=e;if(void 0!==i){const{position:a}=i.attributes;if(void 0!==a)for(let i=0,o=a.count;i<o;i++)e.isMesh?e.getVertexPosition(i,r):r.fromBufferAttribute(a,i),e.isSkinnedMesh||r.applyMatrix4(e.matrixWorld),n=t(n,r)}})),n}let Za,eo,to,io;function decompress(e,t=1/0,i=null){eo||(eo=new PlaneGeometry(2,2,1,1)),to||(to=new ShaderMaterial({uniforms:{blitTexture:new Uniform(e)},vertexShader:"\n            varying vec2 vUv;\n            void main(){\n                vUv = uv;\n                gl_Position = vec4(position.xy * 1.0,0.,.999999);\n            }",fragmentShader:"\n            uniform sampler2D blitTexture; \n            varying vec2 vUv;\n\n            void main(){ \n                gl_FragColor = vec4(vUv.xy, 0, 1);\n                \n                #ifdef IS_SRGB\n                gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n                #else\n                gl_FragColor = texture2D( blitTexture, vUv);\n                #endif\n            }"})),to.uniforms.blitTexture.value=e,to.defines.IS_SRGB=e.colorSpace==be,to.needsUpdate=!0,io||(io=new Mesh(eo,to),io.frustrumCulled=!1);const n=new PerspectiveCamera,r=new Scene;r.add(io),i||(i=Za=new WebGLRenderer({antialias:!1})),i.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),i.clear(),i.render(r,n);const a=new Texture$1(i.domElement);return a.minFilter=e.minFilter,a.magFilter=e.magFilter,a.wrapS=e.wrapS,a.wrapT=e.wrapT,a.name=e.name,Za&&(Za.dispose(),Za=null),a}const no={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class GLTFExporter{constructor(){this.pluginCallbacks=[],this.register((function(e){return new GLTFLightExtension(e)})),this.register((function(e){return new GLTFMaterialsUnlitExtension(e)})),this.register((function(e){return new GLTFMaterialsTransmissionExtension(e)})),this.register((function(e){return new GLTFMaterialsVolumeExtension(e)})),this.register((function(e){return new GLTFMaterialsIorExtension(e)})),this.register((function(e){return new GLTFMaterialsSpecularExtension(e)})),this.register((function(e){return new GLTFMaterialsClearcoatExtension(e)})),this.register((function(e){return new GLTFMaterialsIridescenceExtension(e)})),this.register((function(e){return new GLTFMaterialsSheenExtension(e)})),this.register((function(e){return new GLTFMaterialsAnisotropyExtension(e)})),this.register((function(e){return new GLTFMaterialsEmissiveStrengthExtension(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,i,n){const r=new GLTFWriter,a=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)a.push(this.pluginCallbacks[e](r));r.setPlugins(a),r.write(e,t,n).catch(i)}parseAsync(e,t){const i=this;return new Promise((function(n,r){i.parse(e,n,r,t)}))}}const ro=0,so=1,ao=2,oo=3,lo=4,co=5120,ho=5121,uo=5122,Ao=5123,po=5124,mo=5125,go=5126,fo=34962,vo=34963,Eo=9728,yo=9729,_o=9984,xo=9985,So=9986,Co=9987,Mo=33071,bo=33648,Io=10497,wo="KHR_mesh_quantization",To={};To[1003]=Eo,To[1004]=_o,To[1005]=So,To[1006]=yo,To[1007]=xo,To[1008]=Co,To[1001]=Mo,To[1e3]=Io,To[1002]=bo;const Bo={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Ro=new Color;function equalArray(e,t){return e.length===t.length&&e.every((function(e,i){return e===t[i]}))}function getPaddedBufferSize(e){return 4*Math.ceil(e/4)}function getPaddedArrayBuffer(e,t=0){const i=getPaddedBufferSize(e.byteLength);if(i!==e.byteLength){const n=new Uint8Array(i);if(n.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;r<i;r++)n[r]=t;return n.buffer}return e}function getCanvas(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function getToBlobPromise(e,t){if(void 0!==e.toBlob)return new Promise((i=>e.toBlob(i,t)));let i;return"image/jpeg"===t?i=.92:"image/webp"===t&&(i=.8),e.convertToBlob({type:t,quality:i})}class GLTFWriter{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(e){this.plugins=e}async write(e,t,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(e),await Promise.all(this.pending);const n=this,r=n.buffers,a=n.json;i=n.options;const o=n.extensionsUsed,l=n.extensionsRequired,c=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(o),d=Object.keys(l);if(h.length>0&&(a.extensionsUsed=h),d.length>0&&(a.extensionsRequired=d),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=c.size),!0===i.binary){const e=new FileReader;e.readAsArrayBuffer(c),e.onloadend=function(){const i=getPaddedArrayBuffer(e.result),n=new DataView(new ArrayBuffer(8));n.setUint32(0,i.byteLength,!0),n.setUint32(4,5130562,!0);const r=getPaddedArrayBuffer(function stringToArrayBuffer(e){return(new TextEncoder).encode(e).buffer}(JSON.stringify(a)),32),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 d=new Blob([l,o,r,n,i],{type:"application/octet-stream"}),A=new FileReader;A.readAsArrayBuffer(d),A.onloadend=function(){t(A.result)}}}else if(a.buffers&&a.buffers.length>0){const e=new FileReader;e.readAsDataURL(c),e.onloadend=function(){const i=e.result;a.buffers[0].uri=i,t(a)}}else t(a)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const i=this.options,n=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(i.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],n[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new Vector3;for(let i=0,n=e.count;i<n;i++)if(Math.abs(t.fromBufferAttribute(e,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const i=e.clone(),n=new Vector3;for(let e=0,t=i.count;e<t;e++)n.fromBufferAttribute(i,e),0===n.x&&0===n.y&&0===n.z?n.setX(1):n.normalize(),i.setXYZ(e,n.x,n.y,n.z);return t.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let i=!1;const n={};0===t.offset.x&&0===t.offset.y||(n.offset=t.offset.toArray(),i=!0),0!==t.rotation&&(n.rotation=t.rotation,i=!0),1===t.repeat.x&&1===t.repeat.y||(n.scale=t.repeat.toArray(),i=!0),i&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=n,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function getEncodingConversion(e){return e.colorSpace===be?function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function LinearToLinear(e){return e}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof CompressedTexture&&(e=decompress(e)),t instanceof CompressedTexture&&(t=decompress(t));const i=e?e.image:null,n=t?t.image:null,r=Math.max(i?i.width:0,n?n.width:0),a=Math.max(i?i.height:0,n?n.height:0),o=getCanvas();o.width=r,o.height=a;const l=o.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,r,a);const c=l.getImageData(0,0,r,a);if(i){l.drawImage(i,0,0,r,a);const t=getEncodingConversion(e),n=l.getImageData(0,0,r,a).data;for(let e=2;e<n.length;e+=4)c.data[e]=256*t(n[e]/256)}if(n){l.drawImage(n,0,0,r,a);const e=getEncodingConversion(t),i=l.getImageData(0,0,r,a).data;for(let t=1;t<i.length;t+=4)c.data[t]=256*e(i[t]/256)}l.putImageData(c,0,0);const h=(e||t).clone();return h.source=new Source(o),h.colorSpace=Me,h.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),h}processBuffer(e){const t=this.json,i=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),i.push(e),0}processBufferView(e,t,i,n,r){const a=this.json;let o;switch(a.bufferViews||(a.bufferViews=[]),t){case co:case ho:o=1;break;case uo:case Ao:o=2;break;default:o=4}const l=getPaddedBufferSize(n*e.itemSize*o),c=new DataView(new ArrayBuffer(l));let h=0;for(let r=i;r<i+n;r++)for(let i=0;i<e.itemSize;i++){let n;e.itemSize>4?n=e.array[r*e.itemSize+i]:(0===i?n=e.getX(r):1===i?n=e.getY(r):2===i?n=e.getZ(r):3===i&&(n=e.getW(r)),!0===e.normalized&&(n=Xe.normalize(n,e.array))),t===go?c.setFloat32(h,n,!0):t===po?c.setInt32(h,n,!0):t===mo?c.setUint32(h,n,!0):t===uo?c.setInt16(h,n,!0):t===Ao?c.setUint16(h,n,!0):t===co?c.setInt8(h,n):t===ho&&c.setUint8(h,n),h+=o}const d={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:l};void 0!==r&&(d.target=r),r===fo&&(d.byteStride=e.itemSize*o),this.byteOffset+=l,a.bufferViews.push(d);return{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,i=t.json;return i.bufferViews||(i.bufferViews=[]),new Promise((function(n){const r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){const e=getPaddedArrayBuffer(r.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,n(i.bufferViews.push(a)-1)}}))}processAccessor(e,t,i,n){const r=this.json;let a;if(e.array.constructor===Float32Array)a=go;else if(e.array.constructor===Int32Array)a=po;else if(e.array.constructor===Uint32Array)a=mo;else if(e.array.constructor===Int16Array)a=uo;else if(e.array.constructor===Uint16Array)a=Ao;else if(e.array.constructor===Int8Array)a=co;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);a=ho}if(void 0===i&&(i=0),void 0===n&&(n=e.count),0===n)return null;const o=function getMinMax(e,t,i){const n={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=t;r<t+i;r++)for(let t=0;t<e.itemSize;t++){let i;e.itemSize>4?i=e.array[r*e.itemSize+t]:(0===t?i=e.getX(r):1===t?i=e.getY(r):2===t?i=e.getZ(r):3===t&&(i=e.getW(r)),!0===e.normalized&&(i=Xe.normalize(i,e.array))),n.min[t]=Math.min(n.min[t],i),n.max[t]=Math.max(n.max[t],i)}return n}(e,i,n);let l;void 0!==t&&(l=e===t.index?vo:fo);const c=this.processBufferView(e,a,i,n,l),h={bufferView:c.id,byteOffset:c.byteOffset,componentType:a,count:n,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(h)-1}processImage(e,t,i,n="image/png"){if(null!==e){const r=this,a=r.cache,o=r.json,l=r.options,c=r.pending;a.images.has(e)||a.images.set(e,{});const h=a.images.get(e),d=n+":flipY/"+i.toString();if(void 0!==h[d])return h[d];o.images||(o.images=[]);const A={mimeType:n},p=getCanvas();p.width=Math.min(e.width,l.maxTextureSize),p.height=Math.min(e.height,l.maxTextureSize);const m=p.getContext("2d");if(!0===i&&(m.translate(0,p.height),m.scale(1,-1)),void 0!==e.data){t!==ee&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const i=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<i.length;t+=4)i[t+0]=e.data[t+0],i[t+1]=e.data[t+1],i[t+2]=e.data[t+2],i[t+3]=e.data[t+3];m.putImageData(new ImageData(i,e.width,e.height),0,0)}else m.drawImage(e,0,0,p.width,p.height);!0===l.binary?c.push(getToBlobPromise(p,n).then((e=>r.processBufferViewImage(e))).then((e=>{A.bufferView=e}))):void 0!==p.toDataURL?A.uri=p.toDataURL(n):c.push(getToBlobPromise(p,n).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{A.uri=e})));const g=o.images.push(A)-1;return h[d]=g,g}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const i={magFilter:To[e.magFilter],minFilter:To[e.minFilter],wrapS:To[e.wrapS],wrapT:To[e.wrapT]};return t.samplers.push(i)-1}processTexture(e){const t=this.options,i=this.cache,n=this.json;if(i.textures.has(e))return i.textures.get(e);n.textures||(n.textures=[]),e instanceof CompressedTexture&&(e=decompress(e,t.maxTextureSize));let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");const a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(a.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,a)}));const o=n.textures.push(a)-1;return i.textures.set(e,o),o}processMaterial(e){const t=this.cache,i=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;i.materials||(i.materials=[]);const n={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(equalArray(r,[1,1,1,1])||(n.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(n.pbrMetallicRoughness.metallicFactor=e.metalness,n.pbrMetallicRoughness.roughnessFactor=e.roughness):(n.pbrMetallicRoughness.metallicFactor=.5,n.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),i={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(i,t),n.pbrMetallicRoughness.metallicRoughnessTexture=i}if(e.map){const t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),n.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(n.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),n.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),n.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),n.occlusionTexture=t}e.transparent?n.alphaMode="BLEND":e.alphaTest>0&&(n.alphaMode="MASK",n.alphaCutoff=e.alphaTest),2===e.side&&(n.doubleSided=!0),""!==e.name&&(n.name=e.name),this.serializeUserData(e,n),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,n)}));const a=i.materials.push(n)-1;return t.materials.set(e,a),a}processMesh(e){const t=this.cache,i=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,i=e.material.length;t<i;t++)n.push(e.material[t].uuid);else n.push(e.material.uuid);const r=n.join(":");if(t.meshes.has(r))return t.meshes.get(r);const a=e.geometry;let o;o=e.isLineSegments?so:e.isLineLoop?ao:e.isLine?oo:e.isPoints?ro:e.material.wireframe?so:lo;const l={},c={},h=[],d=[],A={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=a.getAttribute("normal");void 0===p||this.isNormalizedNormalAttribute(p)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let m=null;for(let e in a.attributes){if("morph"===e.slice(0,5))continue;const i=a.attributes[e];e=A[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(i))){c[e]=t.attributes.get(this.getUID(i));continue}m=null;const n=i.array;"JOINTS_0"!==e||n instanceof Uint16Array||n instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),m=new BufferAttribute(new Uint16Array(n),i.itemSize,i.normalized));const r=this.processAccessor(m||i,a);null!==r&&(e.startsWith("_")||this.detectMeshQuantization(e,i),c[e]=r,t.attributes.set(this.getUID(i),r))}if(void 0!==p&&a.setAttribute("normal",p),0===Object.keys(c).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const i=[],n=[],r={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){const l={};let c=!1;for(const e in a.morphAttributes){if("position"!==e&&"normal"!==e){c||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),c=!0);continue}const i=a.morphAttributes[e][o],n=e.toUpperCase(),r=a.attributes[e];if(t.attributes.has(this.getUID(i,!0))){l[n]=t.attributes.get(this.getUID(i,!0));continue}const h=i.clone();if(!a.morphTargetsRelative)for(let e=0,t=i.count;e<t;e++)for(let t=0;t<i.itemSize;t++)0===t&&h.setX(e,i.getX(e)-r.getX(e)),1===t&&h.setY(e,i.getY(e)-r.getY(e)),2===t&&h.setZ(e,i.getZ(e)-r.getZ(e)),3===t&&h.setW(e,i.getW(e)-r.getW(e));l[n]=this.processAccessor(h,a),t.attributes.set(this.getUID(r,!0),l[n])}d.push(l),i.push(e.morphTargetInfluences[o]),void 0!==e.morphTargetDictionary&&n.push(r[o])}l.weights=i,n.length>0&&(l.extras={},l.extras.targetNames=n)}const g=Array.isArray(e.material);if(g&&0===a.groups.length)return null;const f=g?e.material:[e.material],v=g?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,i=v.length;e<i;e++){const i={mode:o,attributes:c};if(this.serializeUserData(a,i),d.length>0&&(i.targets=d),null!==a.index){let n=this.getUID(a.index);void 0===v[e].start&&void 0===v[e].count||(n+=":"+v[e].start+":"+v[e].count),t.attributes.has(n)?i.indices=t.attributes.get(n):(i.indices=this.processAccessor(a.index,a,v[e].start,v[e].count),t.attributes.set(n,i.indices)),null===i.indices&&delete i.indices}const n=this.processMaterial(f[v[e].materialIndex]);null!==n&&(i.material=n),h.push(i)}l.primitives=h,i.meshes||(i.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,l)}));const E=i.meshes.push(l)-1;return t.meshes.set(r,E),E}detectMeshQuantization(e,t){if(this.extensionsUsed[wo])return;let i;switch(t.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}t.normalized&&(i+=" normalized");const n=e.split("_",1)[0];no[n]&&no[n].includes(i)&&(this.extensionsUsed[wo]=!0,this.extensionsRequired[wo]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const i=e.isOrthographicCamera,n={type:i?"orthographic":"perspective"};return i?n.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:Xe.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(n.name=e.type),t.cameras.push(n)-1}processAnimation(e,t){const i=this.json,n=this.nodeMap;i.animations||(i.animations=[]);const r=(e=GLTFExporter.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],o=[];for(let e=0;e<r.length;++e){const i=r[e],l=PropertyBinding.parseTrackName(i.name);let c=PropertyBinding.findNode(t,l.nodeName);const h=Bo[l.propertyName];if("bones"===l.objectName&&(c=!0===c.isSkinnedMesh?c.skeleton.getBoneByName(l.objectIndex):void 0),!c||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',i.name),null;const d=1;let A,p=i.values.length/i.times.length;h===Bo.morphTargetInfluences&&(p/=c.morphTargetInfluences.length),!0===i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(A="CUBICSPLINE",p/=3):A=i.getInterpolation()===fe?"STEP":"LINEAR",o.push({input:this.processAccessor(new BufferAttribute(i.times,d)),output:this.processAccessor(new BufferAttribute(i.values,p)),interpolation:A}),a.push({sampler:o.length-1,target:{node:n.get(c),path:h}})}return i.animations.push({name:e.name||"clip_"+i.animations.length,samplers:o,channels:a}),i.animations.length-1}processSkin(e){const t=this.json,i=this.nodeMap,n=t.nodes[i.get(e)],r=e.skeleton;if(void 0===r)return null;const a=e.skeleton.bones[0];if(void 0===a)return null;const o=[],l=new Float32Array(16*r.bones.length),c=new Matrix4;for(let t=0;t<r.bones.length;++t)o.push(i.get(r.bones[t])),c.copy(r.boneInverses[t]),c.multiply(e.bindMatrix).toArray(l,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new BufferAttribute(l,16)),joints:o,skeleton:i.get(a)});return n.skin=t.skins.length-1}processNode(e){const t=this.json,i=this.options,n=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(i.trs){const t=e.quaternion.toArray(),i=e.position.toArray(),n=e.scale.toArray();equalArray(t,[0,0,0,1])||(r.rotation=t),equalArray(i,[0,0,0])||(r.translation=i),equalArray(n,[1,1,1])||(r.scale=n)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===function isIdentityMatrix(e){return equalArray(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}(e.matrix)&&(r.matrix=e.matrix.elements);if(""!==e.name&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const t=this.processMesh(e);null!==t&&(r.mesh=t)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let n=0,r=e.children.length;n<r;n++){const r=e.children[n];if(r.visible||!1===i.onlyVisible){const e=this.processNode(r);null!==e&&t.push(e)}}t.length>0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));const a=t.nodes.push(r)-1;return n.set(e,a),a}processScene(e){const t=this.json,i=this.options;t.scenes||(t.scenes=[],t.scene=0);const n={};""!==e.name&&(n.name=e.name),t.scenes.push(n);const r=[];for(let t=0,n=e.children.length;t<n;t++){const n=e.children[t];if(n.visible||!1===i.onlyVisible){const e=this.processNode(n);null!==e&&r.push(e)}}r.length>0&&(n.nodes=r),this.serializeUserData(e,n)}processObjects(e){const t=new Scene;t.name="AuxScene";for(let i=0;i<e.length;i++)t.children.push(e[i]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const i=[];for(let t=0;t<e.length;t++)e[t]instanceof Scene?this.processScene(e[t]):i.push(e[t]);i.length>0&&this.processObjects(i);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let i=0;i<t.animations.length;++i)this.processAnimation(t.animations[i],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,i=this.plugins.length;t<i;t++)e(this.plugins[t])}}class GLTFLightExtension{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const i=this.writer,n=i.json,r=i.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type="directional":e.isPointLight?(a.type="point",e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type="spot",e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.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 o=n.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class GLTFMaterialsUnlitExtension{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class GLTFMaterialsClearcoatExtension{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:i.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};i.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:i.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};i.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:i.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};i.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class GLTFMaterialsIridescenceExtension{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:i.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};i.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:i.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};i.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class GLTFMaterialsTransmissionExtension{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const t={index:i.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};i.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class GLTFMaterialsVolumeExtension{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const i=this.writer,n=i.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const t={index:i.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};i.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class GLTFMaterialsIorExtension{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const i=this.writer.extensionsUsed,n={};n.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}class GLTFMaterialsSpecularExtension{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Ro)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const i=this.writer,n=i.extensionsUsed,r={};if(e.specularIntensityMap){const t={index:i.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};i.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){const t={index:i.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};i.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class GLTFMaterialsSheenExtension{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;const i=this.writer,n=i.extensionsUsed,r={};if(e.sheenRoughnessMap){const t={index:i.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};i.applyTextureTransform(t,e.sheenRoughnessMap),r.sheenRoughnessTexture=t}if(e.sheenColorMap){const t={index:i.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};i.applyTextureTransform(t,e.sheenColorMap),r.sheenColorTexture=t}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;const i=this.writer,n=i.extensionsUsed,r={};if(e.anisotropyMap){const t={index:i.processTexture(e.anisotropyMap)};i.applyTextureTransform(t,e.anisotropyMap),r.anisotropyTexture=t}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;const i=this.writer.extensionsUsed,n={};n.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}GLTFExporter.Utils={insertKeyframe:function(e,t){const i=.001,n=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+n),o=e.createInterpolant(new e.ValueBufferType(n));let l;if(0===e.times.length){r[0]=t;for(let e=0;e<n;e++)a[e]=0;l=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<i)return 0;r[0]=t,r.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,n),l=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<i)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),l=r.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<i)return c;if(e.times[c]<t&&e.times[c+1]>t){r.set(e.times.slice(0,c+1),0),r[c+1]=t,r.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*n),0),a.set(o.evaluate(t),(c+1)*n),a.set(e.values.slice((c+1)*n),(c+2)*n),l=c+1;break}}return e.times=r,e.values=a,l},mergeMorphTargetTracks:function(e,t){const i=[],n={},r=e.tracks;for(let e=0;e<r.length;++e){let a=r[e];const o=PropertyBinding.parseTrackName(a.name),l=PropertyBinding.findNode(t,o.nodeName);if("morphTargetInfluences"!==o.propertyName||void 0===o.propertyIndex){i.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),a=a.clone(),a.setInterpolation(ve)}const c=l.morphTargetInfluences.length,h=l.morphTargetDictionary[o.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let d;if(void 0===n[l.uuid]){d=a.clone();const e=new d.ValueBufferType(c*d.times.length);for(let t=0;t<d.times.length;t++)e[t*c+h]=d.values[t];d.name=(o.nodeName||"")+".morphTargetInfluences",d.values=e,n[l.uuid]=d,i.push(d);continue}const A=a.createInterpolant(new a.ValueBufferType(1));d=n[l.uuid];for(let e=0;e<d.times.length;e++)d.values[e*c+h]=A.evaluate(d.times[e]);for(let e=0;e<a.times.length;e++){const t=this.insertKeyframe(d,a.times[e]);d.values[t*c+h]=a.values[e]}}return e.tracks=i,e}};
/* @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 compatibleObject=e=>void 0!==e.material&&e.userData&&e.userData.variantMaterials&&!!Array.from(e.userData.variantMaterials.values()).filter((e=>compatibleMaterial(e.material))),compatibleMaterial=e=>e&&e.isMaterial&&!Array.isArray(e);class GLTFExporterMaterialsVariantsExtension{constructor(e){this.writer=e,this.name="KHR_materials_variants",this.variantNames=[]}beforeParse(e){const t=new Set;for(const i of e)i.traverse((e=>{if(!compatibleObject(e))return;const i=e.userData.variantMaterials,n=e.userData.variantData;for(const[e,r]of n){const n=i.get(r.index);n&&compatibleMaterial(n.material)&&t.add(e)}}));t.forEach((e=>this.variantNames.push(e)))}writeMesh(e,t){if(!compatibleObject(e))return;const i=e.userData,n=i.variantMaterials,r=i.variantData,a=new Map,o=new Map,l=Array.from(r.values()).sort(((e,t)=>e.index-t.index));for(const[e,t]of l.entries())o.set(t.index,e);for(const e of r.values()){const t=n.get(e.index);if(!t||!compatibleMaterial(t.material))continue;const i=this.writer.processMaterial(t.material);a.has(i)||a.set(i,{material:i,variants:[]}),a.get(i).variants.push(o.get(e.index))}const c=Array.from(a.values()).map((e=>e.variants.sort(((e,t)=>e-t))&&e)).sort(((e,t)=>e.material-t.material));if(0===c.length)return;const h=compatibleMaterial(i.originalMaterial)?this.writer.processMaterial(i.originalMaterial):-1;for(const e of t.primitives)h>=0&&(e.material=h),e.extensions=e.extensions||{},e.extensions[this.name]={mappings:c}}afterParse(){if(0===this.variantNames.length)return;const e=this.writer.json;e.extensions=e.extensions||{};const t=this.variantNames.map((e=>({name:e})));e.extensions[this.name]={variants:t},this.writer.extensionsUsed[this.name]=!0}}class SessionLightProbe{constructor(e,t,i,n,r){this.xrLight=e,this.renderer=t,this.lightProbe=i,this.xrWebGLBinding=null,this.estimationStartCallback=r,this.frameCallback=this.onXRFrame.bind(this);const a=t.xr.getSession();if(n&&"XRWebGLBinding"in window){const i=new WebGLCubeRenderTarget(16);e.environment=i.texture;const n=t.getContext();switch(a.preferredReflectionFormat){case"srgba8":n.getExtension("EXT_sRGB");break;case"rgba16f":n.getExtension("OES_texture_half_float")}this.xrWebGLBinding=new XRWebGLBinding(a,n),this.lightProbe.addEventListener("reflectionchange",(()=>{this.updateReflection()}))}a.requestAnimationFrame(this.frameCallback)}updateReflection(){const e=this.renderer.properties.get(this.xrLight.environment);if(e){const t=this.xrWebGLBinding.getReflectionCubeMap(this.lightProbe);t&&(e.__webglTexture=t,this.xrLight.environment.needsPMREMUpdate=!0)}}onXRFrame(e,t){if(!this.xrLight)return;t.session.requestAnimationFrame(this.frameCallback);const i=t.getLightEstimate(this.lightProbe);if(i){this.xrLight.lightProbe.sh.fromArray(i.sphericalHarmonicsCoefficients),this.xrLight.lightProbe.intensity=1;const e=Math.max(1,Math.max(i.primaryLightIntensity.x,Math.max(i.primaryLightIntensity.y,i.primaryLightIntensity.z)));this.xrLight.directionalLight.color.setRGB(i.primaryLightIntensity.x/e,i.primaryLightIntensity.y/e,i.primaryLightIntensity.z/e),this.xrLight.directionalLight.intensity=e,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 XREstimatedLight extends Group{constructor(e,t=!0){super(),this.lightProbe=new LightProbe,this.lightProbe.intensity=0,this.add(this.lightProbe),this.directionalLight=new DirectionalLight,this.directionalLight.intensity=0,this.add(this.directionalLight),this.environment=null;let i=null,n=!1;e.xr.addEventListener("sessionstart",(()=>{const r=e.xr.getSession();"requestLightProbe"in r&&r.requestLightProbe({reflectionFormat:r.preferredReflectionFormat}).then((r=>{i=new SessionLightProbe(this,e,r,t,(()=>{n=!0,this.dispatchEvent({type:"estimationstart"})}))}))})),e.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 Damper{constructor(e=50){this.velocity=0,this.naturalFrequency=0,this.setDecayTime(e)}setDecayTime(e){this.naturalFrequency=1/Math.max(.001,e)}update(e,t,i,n){const r=2e-4*this.naturalFrequency;if(null==e||0===n)return t;if(e===t&&0===this.velocity)return t;if(i<0)return e;const a=e-t,o=this.velocity+this.naturalFrequency*a,l=a+i*o,c=Math.exp(-this.naturalFrequency*i),h=(o-this.naturalFrequency*l)*c,d=-this.naturalFrequency*(h+o*c);return Math.abs(h)<r*Math.abs(n)&&d*a>=0?(this.velocity=0,t):(this.velocity=h,t+l*c)}}
/* @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 Lo=.2,Do=Math.PI/24,Uo=new Vector2,addCorner=(e,t,i)=>{let n=t>0?i>0?0:-Math.PI/2:i>0?Math.PI/2:Math.PI;for(let r=0;r<=12;++r)e.push(t+.17*Math.cos(n),i+.17*Math.sin(n),0,t+Lo*Math.cos(n),i+Lo*Math.sin(n),0),n+=Do};class PlacementBox extends Mesh{constructor(e,t){const i=new BufferGeometry,n=[],r=[],{size:a,boundingBox:o}=e,l=a.x/2,c=("back"===t?a.y:a.z)/2;addCorner(r,l,c),addCorner(r,-l,c),addCorner(r,-l,-c),addCorner(r,l,-c);const h=r.length/3;for(let e=0;e<h-2;e+=2)n.push(e,e+1,e+3,e,e+3,e+2);const d=h-2;n.push(d,d+1,1,d,1,0),i.setAttribute("position",new Float32BufferAttribute(r,3)),i.setIndex(n),super(i),this.side=t;const A=this.material;switch(A.side=2,A.transparent=!0,A.opacity=0,this.goalOpacity=0,this.opacityDamper=new Damper,this.hitPlane=new Mesh(new PlaneGeometry(2*(l+Lo),2*(c+Lo))),this.hitPlane.visible=!1,this.hitPlane.material.side=2,this.add(this.hitPlane),o.getCenter(this.position),t){case"bottom":this.rotateX(-Math.PI/2),this.shadowHeight=o.min.y,this.position.y=this.shadowHeight;break;case"back":this.shadowHeight=o.min.z,this.position.z=this.shadowHeight}e.target.add(this),this.offsetHeight=0}getHit(e,t,i){Uo.set(t,-i),this.hitPlane.visible=!0;const n=e.positionAndNormalFromPoint(Uo,this.hitPlane);return this.hitPlane.visible=!1,null==n?null:n.position}getExpandedHit(e,t,i){this.hitPlane.scale.set(1e3,1e3,1e3),this.hitPlane.updateMatrixWorld();const n=this.getHit(e,t,i);return this.hitPlane.scale.set(1,1,1),n}set offsetHeight(e){e-=.001,"back"===this.side?this.position.z=this.shadowHeight+e:this.position.y=this.shadowHeight+e}get offsetHeight(){return"back"===this.side?this.position.z-this.shadowHeight:this.position.y-this.shadowHeight}set show(e){this.goalOpacity=e?.75:0}updateOpacity(e){const t=this.material;t.opacity=this.opacityDamper.update(t.opacity,this.goalOpacity,e,1),this.visible=t.opacity>0}dispose(){var e;const{geometry:t,material:i}=this.hitPlane;t.dispose(),i.dispose(),this.geometry.dispose(),this.material.dispose(),null===(e=this.parent)||void 0===e||e.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 numberNode=(e,t)=>({type:"number",number:e,unit:t}),Po=(()=>{const e={};return t=>{const i=t;if(i in e)return e[i];const n=[];let r=0;for(;t;){if(++r>1e3){t="";break}const e=Fo(t),i=e.nodes[0];if(null==i||0===i.terms.length)break;n.push(i),t=e.remainingInput}return e[i]=n}})(),Fo=(()=>{const e=/^(\-\-|[a-z\u0240-\uffff])/i,t=/^([\*\+\/]|[\-]\s)/i,i=/^[\),]/;return n=>{const r=[];for(;n.length&&(n=n.trim(),!i.test(n));)if("("===n[0]){const{nodes:e,remainingInput:t}=parseFunctionArguments(n);n=t,r.push({type:"function",name:{type:"ident",value:"calc"},arguments:e})}else if(e.test(n)){const e=No(n),t=e.nodes[0];if("("===(n=e.remainingInput)[0]){const{nodes:e,remainingInput:i}=parseFunctionArguments(n);r.push({type:"function",name:t,arguments:e}),n=i}else r.push(t)}else if(t.test(n))r.push({type:"operator",value:n[0]}),n=n.slice(1);else{const{nodes:e,remainingInput:t}="#"===n[0]?Oo(n):Qo(n);if(0===e.length)break;r.push(e[0]),n=t}return{nodes:[{type:"expression",terms:r}],remainingInput:n}}})(),No=(()=>{const e=/[^a-z0-9_\-\u0240-\uffff]/i;return t=>{const i=t.match(e);return{nodes:[{type:"ident",value:null==i?t:t.substr(0,i.index)}],remainingInput:null==i?"":t.substr(i.index)}}})(),Qo=(()=>{const e=/[\+\-]?(\d+[\.]\d+|\d+|[\.]\d+)([eE][\+\-]?\d+)?/,t=/^[a-z%]+/i,i=/^(m|mm|cm|rad|deg|[%])$/;return n=>{const r=n.match(e),a=null==r?"0":r[0],o=(n=null==a?n:n.slice(a.length)).match(t);let l=null!=o&&""!==o[0]?o[0]:null;const c=null==o?n:n.slice(l.length);return null==l||i.test(l)||(l=null),{nodes:[{type:"number",number:parseFloat(a)||0,unit:l}],remainingInput:c}}})(),Oo=(()=>{const e=/^[a-f0-9]*/i;return t=>{const i=(t=t.slice(1).trim()).match(e);return{nodes:null==i?[]:[{type:"hex",value:i[0]}],remainingInput:null==i?t:t.slice(i[0].length)}}})(),parseFunctionArguments=e=>{const t=[];for(e=e.slice(1).trim();e.length;){const i=Fo(e);if(t.push(i.nodes[0]),","===(e=i.remainingInput.trim())[0])e=e.slice(1).trim();else if(")"===e[0]){e=e.slice(1);break}}return{nodes:t,remainingInput:e}},ko=Symbol("visitedTypes");class ASTWalker{constructor(e){this[ko]=e}walk(e,t){const i=e.slice();for(;i.length;){const e=i.shift();switch(this[ko].indexOf(e.type)>-1&&t(e),e.type){case"expression":i.unshift(...e.terms);break;case"function":i.unshift(e.name,...e.arguments)}}}}const Go=Object.freeze({type:"number",number:0,unit:null}),degreesToRadians=(e,t=0)=>{let{number:i,unit:n}=e;if(isFinite(i)){if("rad"===e.unit||null==e.unit)return e}else i=t,n="rad";return{type:"number",number:("deg"===n&&null!=i?i:0)*Math.PI/180,unit:"rad"}},lengthToBaseMeters=(e,t=0)=>{let i,{number:n,unit:r}=e;if(isFinite(n)){if("m"===e.unit)return e}else n=t,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"}},Vo=(()=>{const identity=e=>e,e={rad:identity,deg:degreesToRadians,m:identity,mm:lengthToBaseMeters,cm:lengthToBaseMeters};return(t,i=Go)=>{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 Ho,zo,Wo;const qo=Symbol("evaluate"),Xo=Symbol("lastValue");class Evaluator{constructor(){this[Ho]=null}static evaluatableFor(e,t=Go){if(e instanceof Evaluator)return e;if("number"===e.type)return"%"===e.unit?new PercentageEvaluator(e,t):e;switch(e.name.value){case"calc":return new CalcEvaluator(e,t);case"env":return new EnvEvaluator(e)}return Go}static evaluate(e){return e instanceof Evaluator?e.evaluate():e}static isConstant(e){return!(e instanceof Evaluator)||e.isConstant}static applyIntrinsics(e,t){const{basis:i,keywords:n}=t,{auto:r}=n;return i.map(((t,i)=>{const a=null==r[i]?t:r[i];let o=e[i]?e[i]:a;if("ident"===o.type){const e=o.value;e in n&&(o=n[e][i])}return null!=o&&"ident"!==o.type||(o=a),"%"===o.unit?numberNode(o.number/100*t.number,t.unit):(o=Vo(o,t),o.unit!==t.unit?t:o)}))}get isConstant(){return!1}evaluate(){return this.isConstant&&null!=this[Xo]||(this[Xo]=this[qo]()),this[Xo]}}Ho=Xo;const jo=Symbol("percentage"),Yo=Symbol("basis");class PercentageEvaluator extends Evaluator{constructor(e,t){super(),this[jo]=e,this[Yo]=t}get isConstant(){return!0}[qo](){return numberNode(this[jo].number/100*this[Yo].number,this[Yo].unit)}}const Ko=Symbol("identNode");class EnvEvaluator extends Evaluator{constructor(e){super(),this[zo]=null;const t=e.arguments.length?e.arguments[0].terms[0]:null;null!=t&&"ident"===t.type&&(this[Ko]=t)}get isConstant(){return!1}[(zo=Ko,qo)](){if(null!=this[Ko]&&"window-scroll-y"===this[Ko].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 Go}}const $o=/[\*\/]/,Jo=Symbol("evaluator");class CalcEvaluator extends Evaluator{constructor(e,t=Go){if(super(),this[Wo]=null,1!==e.arguments.length)return;const i=e.arguments[0].terms.slice(),n=[];for(;i.length;){const e=i.shift();if(n.length>0){const i=n[n.length-1];if("operator"===i.type&&$o.test(i.value)){const i=n.pop(),r=n.pop();if(null==r)return;n.push(new OperatorEvaluator(i,Evaluator.evaluatableFor(r,t),Evaluator.evaluatableFor(e,t)));continue}}n.push("operator"===e.type?e:Evaluator.evaluatableFor(e,t))}for(;n.length>2;){const[e,i,r]=n.splice(0,3);if("operator"!==i.type)return;n.unshift(new OperatorEvaluator(i,Evaluator.evaluatableFor(e,t),Evaluator.evaluatableFor(r,t)))}1===n.length&&(this[Jo]=n[0])}get isConstant(){return null==this[Jo]||Evaluator.isConstant(this[Jo])}[(Wo=Jo,qo)](){return null!=this[Jo]?Evaluator.evaluate(this[Jo]):Go}}const Zo=Symbol("operator"),el=Symbol("left"),tl=Symbol("right");class OperatorEvaluator extends Evaluator{constructor(e,t,i){super(),this[Zo]=e,this[el]=t,this[tl]=i}get isConstant(){return Evaluator.isConstant(this[el])&&Evaluator.isConstant(this[tl])}[qo](){const e=Vo(Evaluator.evaluate(this[el])),t=Vo(Evaluator.evaluate(this[tl])),{number:i,unit:n}=e,{number:r,unit:a}=t;if(null!=a&&null!=n&&a!=n)return Go;const o=n||a;let l;switch(this[Zo].value){case"+":l=i+r;break;case"-":l=i-r;break;case"/":l=i/r;break;case"*":l=i*r;break;default:return Go}return{type:"number",number:l,unit:o}}}const il=Symbol("evaluatables"),nl=Symbol("intrinsics");class StyleEvaluator extends Evaluator{constructor(e,t){super(),this[nl]=t;const i=e[0],n=null!=i?i.terms:[];this[il]=t.basis.map(((e,t)=>{const i=n[t];return null==i?{type:"ident",value:"auto"}:"ident"===i.type?i:Evaluator.evaluatableFor(i,e)}))}get isConstant(){for(const e of this[il])if(!Evaluator.isConstant(e))return!1;return!0}[qo](){const e=this[il].map((e=>Evaluator.evaluate(e)));return Evaluator.applyIntrinsics(e,this[nl]).map((e=>e.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 rl,sl,al,ol;const ll=Symbol("instances"),cl=Symbol("activateListener"),hl=Symbol("deactivateListener"),ul=Symbol("notifyInstances"),dl=Symbol("notify"),Al=Symbol("callback");class ScrollObserver{constructor(e){this[Al]=e}static[ul](){for(const e of ScrollObserver[ll])e[dl]()}static[(rl=ll,cl)](){window.addEventListener("scroll",this[ul],{passive:!0})}static[hl](){window.removeEventListener("scroll",this[ul])}observe(){0===ScrollObserver[ll].size&&ScrollObserver[cl](),ScrollObserver[ll].add(this)}disconnect(){ScrollObserver[ll].delete(this),0===ScrollObserver[ll].size&&ScrollObserver[hl]()}[dl](){this[Al]()}}ScrollObserver[rl]=new Set;const pl=Symbol("computeStyleCallback"),ml=Symbol("astWalker"),gl=Symbol("dependencies"),fl=Symbol("onScroll");class StyleEffector{constructor(e){this[sl]={},this[al]=new ASTWalker(["function"]),this[ol]=()=>{this[pl]({relatedState:"window-scroll"})},this[pl]=e}observeEffectsFor(e){const t={},i=this[gl];this[ml].walk(e,(e=>{const{name:n}=e,r=e.arguments[0].terms[0];if("env"===n.value&&null!=r&&"ident"===r.type&&"window-scroll-y"===r.value)if(null==t["window-scroll"]){const e="window-scroll"in i?i["window-scroll"]:new ScrollObserver(this[fl]);e.observe(),delete i["window-scroll"],t["window-scroll"]=e}}));for(const e in i){i[e].disconnect()}this[gl]=t}dispose(){for(const e in this[gl]){this[gl][e].disconnect()}}}sl=gl,al=ml,ol=fl;
/* @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 style=e=>{const t=e.observeEffects||!1,i=e.intrinsics instanceof Function?e.intrinsics:()=>e.intrinsics;return(n,r)=>{const a=n.updated,o=n.connectedCallback,l=n.disconnectedCallback,c=Symbol(`${r}StyleEffector`),h=Symbol(`${r}StyleEvaluator`),d=Symbol(`${r}UpdateEvaluator`),A=Symbol(`${r}EvaluateAndSync`);Object.defineProperties(n,{[c]:{value:null,writable:!0},[h]:{value:null,writable:!0},[d]:{value:function(){const e=Po(this[r]);this[h]=new StyleEvaluator(e,i(this)),null==this[c]&&t&&(this[c]=new StyleEffector((()=>this[A]()))),null!=this[c]&&this[c].observeEffectsFor(e)}},[A]:{value:function(){if(null==this[h])return;const t=this[h].evaluate();this[e.updateHandler](t)}},updated:{value:function(e){e.has(r)&&(this[d](),this[A]()),a.call(this,e)}},connectedCallback:{value:function(){o.call(this),this.requestUpdate(r,this[r])}},disconnectedCallback:{value:function(){l.call(this),null!=this[c]&&(this[c].dispose(),this[c]=null)}}})}},easeInOutQuad=e=>e<.5?2*e*e:(4-2*e)*e-1,interpolate=(e,t,i=easeInOutQuad)=>n=>e+(t-e)*i(n),timeline=e=>{const t=[],i=[];let n=e.initialValue;for(let r=0;r<e.keyframes.length;++r){const a=e.keyframes[r],{value:o,frames:l}=a,c=a.ease||easeInOutQuad,h=interpolate(n,o,c);t.push(h),i.push(l),n=o}return((e,t)=>{const i=t.map((n=0,e=>n+=e));var n;return t=>{t=clamp(t,0,1),t*=i[i.length-1];const n=i.findIndex((e=>e>=t)),r=n<1?0:i[n-1],a=i[n];return e[n]((t-r)/(a-r))}})(t,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 __decorate$6=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};const vl=timeline({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}]}),El=timeline({initialValue:0,keyframes:[{frames:1,value:1},{frames:5,value:1},{frames:1,value:0},{frames:6,value:0}]}),yl="0deg 75deg 105%",_l=["front","right","back","left"],xl=["upper-","","lower-"],Sl="auto",Cl="basic",Ml="wiggle",bl="none",fieldOfViewIntrinsics=()=>({basis:[degreesToRadians(numberNode(30,"deg"))],keywords:{auto:[null]}}),minFieldOfViewIntrinsics=()=>({basis:[degreesToRadians(numberNode(12,"deg"))],keywords:{auto:[null]}}),Il=(()=>{const e=Po(yl)[0].terms,t=Vo(e[0]),i=Vo(e[1]);return e=>{const n=e[sd].idealCameraDistance();return{basis:[t,i,numberNode(n,"m")],keywords:{auto:[null,null,numberNode(105,"%")]}}}})(),minCameraOrbitIntrinsics=e=>{const t=2.2*e[sd].boundingSphere.radius;return{basis:[numberNode(-1/0,"rad"),numberNode(Math.PI/8,"rad"),numberNode(t,"m")],keywords:{auto:[null,null,null]}}},maxCameraOrbitIntrinsics=e=>{const t=Il(e),i=new StyleEvaluator([],t).evaluate()[2];return{basis:[numberNode(1/0,"rad"),numberNode(Math.PI-Math.PI/8,"rad"),numberNode(i,"m")],keywords:{auto:[null,null,null]}}},cameraTargetIntrinsics=e=>{const t=e[sd].boundingBox.getCenter(new Vector3);return{basis:[numberNode(t.x,"m"),numberNode(t.y,"m"),numberNode(t.z,"m")],keywords:{auto:[null,null,null]}}},wl=Math.PI/2,Tl=Math.PI/3,Bl=wl/2,Rl=2*Math.PI,Ll=Symbol("controls"),Dl=Symbol("panElement"),Ul=Symbol("promptElement"),Pl=Symbol("promptAnimatedContainer"),Fl=Symbol("fingerAnimatedContainers"),Nl=Symbol("deferInteractionPrompt"),Ql=Symbol("updateAria"),Ol=Symbol("updateCameraForRadius"),kl=Symbol("cancelPrompts"),Gl=Symbol("onChange"),Vl=Symbol("onPointerChange"),Hl=Symbol("waitingToPromptUser"),zl=Symbol("userHasInteracted"),Wl=Symbol("promptElementVisibleTime"),ql=Symbol("lastPromptOffset"),Xl=Symbol("cancellationSource"),jl=Symbol("lastSpherical"),Yl=Symbol("jumpCamera"),Kl=Symbol("initialized"),$l=Symbol("maintainThetaPhi"),Jl=Symbol("syncCameraOrbit"),Zl=Symbol("syncFieldOfView"),ec=Symbol("syncCameraTarget"),tc=Symbol("syncMinCameraOrbit"),ic=Symbol("syncMaxCameraOrbit"),nc=Symbol("syncMinFieldOfView"),rc=Symbol("syncMaxFieldOfView"),sc=new Vector2,ac=new Vector3,oc=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"}),cc=Math.PI/8,hc=.04,uc={USER_INTERACTION:"user-interaction",NONE:"none",AUTOMATIC:"automatic"};class SmoothControls extends EventDispatcher{constructor(e,t,i){super(),this.camera=e,this.element=t,this.scene=i,this.orbitSensitivity=1,this.inputSensitivity=1,this.changeSource=uc.NONE,this._interactionEnabled=!1,this._disableZoom=!1,this.isUserPointing=!1,this.enablePan=!0,this.enableTap=!0,this.panProjection=new Matrix3,this.panPerPixel=0,this.spherical=new Spherical,this.goalSpherical=new Spherical,this.thetaDamper=new Damper,this.phiDamper=new Damper,this.radiusDamper=new Damper,this.logFov=Math.log(oc.maximumFieldOfView),this.goalLogFov=this.logFov,this.fovDamper=new Damper,this.touchMode=null,this.pointers=[],this.startTime=0,this.startPointerPosition={clientX:0,clientY:0},this.lastSeparation=0,this.touchDecided=!1,this.onContext=e=>{if(this.enablePan)e.preventDefault();else for(const e of this.pointers)this.onPointerUp(new PointerEvent("pointercancel",Object.assign(Object.assign({},this.startPointerPosition),{pointerId:e.id})))},this.touchModeZoom=(e,t)=>{if(!this._disableZoom){const e=this.twoTouchDistance(this.pointers[0],this.pointers[1]),t=hc*(this.lastSeparation-e)*50/this.scene.height;this.lastSeparation=e,this.userAdjustOrbit(0,0,t)}this.panPerPixel>0&&this.movePan(e,t)},this.disableScroll=e=>{e.preventDefault()},this.touchModeRotate=(e,t)=>{const{touchAction:i}=this._options;if(!this.touchDecided&&"none"!==i){this.touchDecided=!0;const n=Math.abs(e),r=Math.abs(t);if(this.changeSource===uc.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(e,t)},this.onPointerDown=e=>{if(this.pointers.length>2)return;const{element:t}=this;0===this.pointers.length&&(t.addEventListener("pointermove",this.onPointerMove),t.addEventListener("pointerup",this.onPointerUp),this.touchMode=null,this.touchDecided=!1,this.startPointerPosition.clientX=e.clientX,this.startPointerPosition.clientY=e.clientY,this.startTime=performance.now());try{t.setPointerCapture(e.pointerId)}catch(e){}this.pointers.push({clientX:e.clientX,clientY:e.clientY,id:e.pointerId}),this.isUserPointing=!1,"touch"===e.pointerType?(this.changeSource=e.altKey?uc.AUTOMATIC:uc.USER_INTERACTION,this.onTouchChange(e)):(this.changeSource=uc.USER_INTERACTION,this.onMouseDown(e)),this.changeSource===uc.USER_INTERACTION&&this.dispatchEvent({type:"user-interaction"})},this.onPointerMove=e=>{const t=this.pointers.find((t=>t.id===e.pointerId));if(null==t)return;if("mouse"===e.pointerType&&0===e.buttons)return void this.onPointerUp(e);const i=this.pointers.length,n=(e.clientX-t.clientX)/i,r=(e.clientY-t.clientY)/i;0===n&&0===r||(t.clientX=e.clientX,t.clientY=e.clientY,"touch"===e.pointerType?(this.changeSource=e.altKey?uc.AUTOMATIC:uc.USER_INTERACTION,null!==this.touchMode&&this.touchMode(n,r)):(this.changeSource=uc.USER_INTERACTION,this.panPerPixel>0?this.movePan(n,r):this.handleSinglePointerMove(n,r)))},this.onPointerUp=e=>{const{element:t}=this,i=this.pointers.findIndex((t=>t.id===e.pointerId));-1!==i&&this.pointers.splice(i,1),this.panPerPixel>0&&!e.altKey&&this.resetRadius(),0===this.pointers.length?(t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),t.removeEventListener("touchmove",this.disableScroll),this.enablePan&&this.enableTap&&this.recenter(e)):null!==this.touchMode&&this.onTouchChange(e),this.scene.element[Dl].style.opacity=0,t.style.cursor="grab",this.panPerPixel=0,this.isUserPointing&&this.dispatchEvent({type:"pointer-change-end"})},this.onWheel=e=>{this.changeSource=uc.USER_INTERACTION;const t=e.deltaY*(1==e.deltaMode?18:1)*hc/30;this.userAdjustOrbit(0,0,t),e.preventDefault(),this.dispatchEvent({type:"user-interaction"})},this.onKeyDown=e=>{const{changeSource:t}=this;this.changeSource=uc.USER_INTERACTION;(e.shiftKey&&this.enablePan?this.panKeyCodeHandler(e):this.orbitZoomKeyCodeHandler(e))?(e.preventDefault(),this.dispatchEvent({type:"user-interaction"})):this.changeSource=t},this._options=Object.assign({},oc),this.setOrbit(0,Math.PI/2,1),this.setFieldOfView(100),this.jumpToGoal()}get interactionEnabled(){return this._interactionEnabled}enableInteraction(){if(!1===this._interactionEnabled){const{element:e}=this;e.addEventListener("pointerdown",this.onPointerDown),e.addEventListener("pointercancel",this.onPointerUp),this._disableZoom||e.addEventListener("wheel",this.onWheel),e.addEventListener("keydown",this.onKeyDown),e.addEventListener("touchmove",(()=>{}),{passive:!1}),e.addEventListener("contextmenu",this.onContext),this.element.style.cursor="grab",this._interactionEnabled=!0,this.updateTouchActionStyle()}}disableInteraction(){if(!0===this._interactionEnabled){const{element:e}=this;e.removeEventListener("pointerdown",this.onPointerDown),e.removeEventListener("pointermove",this.onPointerMove),e.removeEventListener("pointerup",this.onPointerUp),e.removeEventListener("pointercancel",this.onPointerUp),e.removeEventListener("wheel",this.onWheel),e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("contextmenu",this.onContext),e.style.cursor="",this.touchMode=null,this._interactionEnabled=!1,this.updateTouchActionStyle()}}get options(){return this._options}set disableZoom(e){this._disableZoom!=e&&(this._disableZoom=e,!0===e?this.element.removeEventListener("wheel",this.onWheel):this.element.addEventListener("wheel",this.onWheel),this.updateTouchActionStyle())}getCameraSpherical(e=new Spherical){return e.copy(this.spherical)}getFieldOfView(){return this.camera.fov}applyOptions(e){Object.assign(this._options,e),this.setOrbit(),this.setFieldOfView(Math.exp(this.goalLogFov))}updateNearFar(e,t){this.camera.far=0===t?2:t,this.camera.near=Math.max(e,this.camera.far/1e3),this.camera.updateProjectionMatrix()}updateAspect(e){this.camera.aspect=e,this.camera.updateProjectionMatrix()}setOrbit(e=this.goalSpherical.theta,t=this.goalSpherical.phi,i=this.goalSpherical.radius){const{minimumAzimuthalAngle:n,maximumAzimuthalAngle:r,minimumPolarAngle:a,maximumPolarAngle:o,minimumRadius:l,maximumRadius:c}=this._options,{theta:h,phi:d,radius:A}=this.goalSpherical,p=clamp(e,n,r);isFinite(n)||isFinite(r)||(this.spherical.theta=this.wrapAngle(this.spherical.theta-p)+p);const m=clamp(t,a,o),g=clamp(i,l,c);return(p!==h||m!==d||g!==A)&&(!!(isFinite(p)&&isFinite(m)&&isFinite(g))&&(this.goalSpherical.theta=p,this.goalSpherical.phi=m,this.goalSpherical.radius=g,this.goalSpherical.makeSafe(),!0))}setRadius(e){this.goalSpherical.radius=e,this.setOrbit()}setFieldOfView(e){const{minimumFieldOfView:t,maximumFieldOfView:i}=this._options;e=clamp(e,t,i),this.goalLogFov=Math.log(e)}setDamperDecayTime(e){this.thetaDamper.setDecayTime(e),this.phiDamper.setDecayTime(e),this.radiusDamper.setDecayTime(e),this.fovDamper.setDecayTime(e)}adjustOrbit(e,t,i){const{theta:n,phi:r,radius:a}=this.goalSpherical,{minimumRadius:o,maximumRadius:l,minimumFieldOfView:c,maximumFieldOfView:h}=this._options,d=this.spherical.theta-n,A=Math.PI-.001,p=n-clamp(e,-A-d,A-d),m=r-t,g=0===i?0:((i>0?l:o)-a)/(Math.log(i>0?h:c)-this.goalLogFov),f=a+i*(isFinite(g)?g:2*(l-o));if(this.setOrbit(p,m,f),0!==i){const e=this.goalLogFov+i;this.setFieldOfView(Math.exp(e))}}jumpToGoal(){this.update(0,1e4)}update(e,t){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,t,Math.PI),this.spherical.phi=this.phiDamper.update(this.spherical.phi,this.goalSpherical.phi,t,i),this.spherical.radius=this.radiusDamper.update(this.spherical.radius,this.goalSpherical.radius,t,n),this.logFov=this.fovDamper.update(this.logFov,this.goalLogFov,t,1),this.moveCamera(),!0}updateTouchActionStyle(){const{style:e}=this.element;if(this._interactionEnabled){const{touchAction:t}=this._options;this._disableZoom&&"none"!==t?e.touchAction="manipulation":e.touchAction=t}else e.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 Euler(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(e,t,i){this.adjustOrbit(e*this.orbitSensitivity*this.inputSensitivity,t*this.orbitSensitivity*this.inputSensitivity,i*this.inputSensitivity)}wrapAngle(e){const t=(e+Math.PI)/(2*Math.PI);return 2*(t-Math.floor(t))*Math.PI-Math.PI}pixelLengthToSphericalAngle(e){return 2*Math.PI*e/this.scene.height}twoTouchDistance(e,t){const{clientX:i,clientY:n}=e,{clientX:r,clientY:a}=t,o=r-i,l=a-n;return Math.sqrt(o*o+l*l)}handleSinglePointerMove(e,t){const i=this.pixelLengthToSphericalAngle(e),n=this.pixelLengthToSphericalAngle(t);!1===this.isUserPointing&&(this.isUserPointing=!0,this.dispatchEvent({type:"pointer-change-start"})),this.userAdjustOrbit(i,n,0)}initializePan(){const{theta:e,phi:t}=this.spherical,i=e-this.scene.yaw;this.panPerPixel=.018/this.scene.height,this.panProjection.set(-Math.cos(i),-Math.cos(t)*Math.sin(i),0,0,Math.sin(t),0,Math.sin(i),-Math.cos(t)*Math.cos(i),0)}movePan(e,t){const{scene:i}=this,n=ac.set(e,t,0).multiplyScalar(this.inputSensitivity),r=this.spherical.radius*Math.exp(this.logFov)*this.panPerPixel;n.multiplyScalar(r);const a=i.getTarget();a.add(n.applyMatrix3(this.panProjection)),i.boundingSphere.clampPoint(a,a),i.setTarget(a.x,a.y,a.z)}recenter(e){if(performance.now()>this.startTime+300||Math.abs(e.clientX-this.startPointerPosition.clientX)>2||Math.abs(e.clientY-this.startPointerPosition.clientY)>2)return;const{scene:t}=this,i=t.positionAndNormalFromPoint(t.getNDC(e.clientX,e.clientY));if(null==i){const{cameraTarget:e}=t.element;t.element.cameraTarget="",t.element.cameraTarget=e,this.userAdjustOrbit(0,0,1)}else t.target.worldToLocal(i.position),t.setTarget(i.position.x,i.position.y,i.position.z)}resetRadius(){const{scene:e}=this,t=e.positionAndNormalFromPoint(sc.set(0,0));if(null==t)return;e.target.worldToLocal(t.position);const i=e.getTarget(),{theta:n,phi:r}=this.spherical,a=n-e.yaw,o=ac.set(Math.sin(r)*Math.sin(a),Math.cos(r),Math.sin(r)*Math.cos(a)),l=o.dot(t.position.sub(i));i.add(o.multiplyScalar(l)),e.setTarget(i.x,i.y,i.z),this.setOrbit(void 0,void 0,this.goalSpherical.radius-l)}onTouchChange(e){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(),e.altKey||(this.scene.element[Dl].style.opacity=1))}}onMouseDown(e){this.panPerPixel=0,this.enablePan&&(2===e.button||e.ctrlKey||e.metaKey||e.shiftKey)&&(this.initializePan(),this.scene.element[Dl].style.opacity=1),this.element.style.cursor="grabbing"}orbitZoomKeyCodeHandler(e){let t=!0;switch(e.key){case"PageUp":this.userAdjustOrbit(0,0,hc);break;case"PageDown":this.userAdjustOrbit(0,0,-.04);break;case"ArrowUp":this.userAdjustOrbit(0,-cc,0);break;case"ArrowDown":this.userAdjustOrbit(0,cc,0);break;case"ArrowLeft":this.userAdjustOrbit(-cc,0,0);break;case"ArrowRight":this.userAdjustOrbit(cc,0,0);break;default:t=!1}return t}panKeyCodeHandler(e){this.initializePan();let t=!0;switch(e.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:t=!1}return 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.
 */const dc=1/1.3,Ac="not-presenting",pc="session-started",mc="object-placed",gc="failed",fc="tracking",vc="not-tracking",Ec=new Vector3,yc=new Matrix4,_c=new Vector3,xc=new PerspectiveCamera(45,1,.1,100);class ARRenderer extends EventDispatcher{constructor(e){super(),this.renderer=e,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 Vector3,this.placementComplete=!1,this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!1,this.lastDragPosition=new Vector3,this.firstRatio=0,this.lastAngle=0,this.goalPosition=new Vector3,this.goalYaw=0,this.goalScale=1,this.xDamper=new Damper,this.yDamper=new Damper,this.zDamper=new Damper,this.yawDamper=new Damper,this.scaleDamper=new Damper,this.onExitWebXRButtonContainerClick=()=>this.stopPresenting(),this.onUpdateScene=()=>{null!=this.placementBox&&this.isPresenting&&(this.placementBox.dispose(),this.placementBox=new PlacementBox(this.presentedScene,this.placeOnWall?"back":"bottom"))},this.onSelectStart=e=>{const t=this.transientHitTestSource;if(null==t)return;const i=this.frame.getHitTestResultsForTransientInput(t),n=this.presentedScene,r=this.placementBox;if(1===i.length){this.inputSource=e.inputSource;const{axes:t}=this.inputSource.gamepad,i=r.getHit(this.presentedScene,t[0],t[1]);r.show=!0,null!=i?(this.isTranslating=!0,this.lastDragPosition.copy(i)):!1===this.placeOnWall&&(this.isRotating=!0,this.lastAngle=1.5*t[0])}else if(2===i.length){r.show=!0,this.isTwoFingering=!0;const{separation:e}=this.fingerPolar(i);this.firstRatio=e/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=e.threeRenderer,this.threeRenderer.xr.enabled=!0}async resolveARSession(){assertIsArCandidate();const e=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(e),this.threeRenderer.xr.cameraAutoUpdate=!1,e}get presentedScene(){return this._presentedScene}async supportsPresentation(){try{return assertIsArCandidate(),await navigator.xr.isSessionSupported("immersive-ar")}catch(e){return console.warn("Request to present in WebXR denied:"),console.warn(e),console.warn("Falling back to next ar-mode"),!1}}async present(e,t=!1){this.isPresenting&&console.warn("Cannot present while a model is already presenting");let i=new Promise(((e,t)=>{requestAnimationFrame((()=>e()))}));e.setHotspotsVisibility(!1),e.queueRender(),await i,this._presentedScene=e,this.overlay=e.element.shadowRoot.querySelector("div.default"),!0===t&&(this.xrLight=new XREstimatedLight(this.threeRenderer),this.xrLight.addEventListener("estimationstart",(()=>{if(!this.isPresenting||null==this.xrLight)return;const e=this.presentedScene;e.add(this.xrLight),e.environment=this.xrLight.environment})));const n=await this.resolveARSession();n.addEventListener("end",(()=>{this.postSessionCleanup()}),{once:!0});const r=e.element.shadowRoot.querySelector(".slot.exit-webxr-ar-button");r.classList.add("enabled"),r.addEventListener("click",this.onExitWebXRButtonContainerClick),this.exitWebXRButtonContainer=r;const a=await n.requestReferenceSpace("viewer");this.tracking=!0,this.frames=0,this.initialized=!1,this.turntableRotation=e.yaw,this.goalYaw=e.yaw,this.goalScale=1,e.background=null,this.oldShadowIntensity=e.shadowIntensity,e.setShadowIntensity(.01),this.oldTarget.copy(e.getTarget()),e.element.addEventListener("load",this.onUpdateScene);const o=20*Math.PI/180,l=!0===this.placeOnWall?void 0:new XRRay(new DOMPoint(0,0,0),{x:0,y:-Math.sin(o),z:-Math.cos(o)});n.requestHitTestSource({space:a,offsetRay:l}).then((e=>{this.initialHitSource=e})),this.currentSession=n,this.placementBox=new PlacementBox(e,this.placeOnWall?"back":"bottom"),this.placementComplete=!1,this.lastTick=performance.now(),this.dispatchEvent({type:"status",status:pc})}async stopPresenting(){if(!this.isPresenting)return;const e=new Promise((e=>{this.resolveCleanup=e}));try{await this.currentSession.end(),await e}catch(e){console.warn("Error while trying to end WebXR AR session"),console.warn(e),this.postSessionCleanup()}}get isPresenting(){return null!=this.presentedScene}get target(){return this.oldTarget}updateTarget(){const e=this.presentedScene;if(null!=e){const t=e.getTarget();this.oldTarget.copy(t),this.placeOnWall?t.z=e.boundingBox.min.z:t.y=e.boundingBox.min.y,e.setTarget(t.x,t.y,t.z)}}postSessionCleanup(){const e=this.currentSession;null!=e&&(e.removeEventListener("selectstart",this.onSelectStart),e.removeEventListener("selectend",this.onSelectEnd),this.currentSession=null);const t=this.presentedScene;if(this._presentedScene=null,null!=t){const{element:e}=t;null!=this.xrLight&&(t.remove(this.xrLight),this.xrLight.dispose(),this.xrLight=null),t.position.set(0,0,0),t.scale.set(1,1,1),t.setShadowOffset(0);const i=this.turntableRotation;null!=i&&(t.yaw=i);const n=this.oldShadowIntensity;null!=n&&t.setShadowIntensity(n),t.setEnvironmentAndSkybox(e[Ps],e[Fs]);const r=this.oldTarget;t.setTarget(r.x,r.y,r.z),t.xrCamera=null,t.element.removeEventListener("load",this.onUpdateScene),t.orientHotspots(0),e.requestUpdate("cameraTarget"),e.requestUpdate("maxCameraOrbit"),e[cd](e.getBoundingClientRect()),requestAnimationFrame((()=>{t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:uc.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:Ac})}updateView(e){const t=this.presentedScene,i=this.threeRenderer.xr;i.updateCamera(xc),t.xrCamera=i.getCamera();const{elements:n}=t.getCamera().matrixWorld;if(t.orientHotspots(Math.atan2(n[1],n[5])),this.initialized||(this.placeInitially(),this.initialized=!0),e.requestViewportScale&&e.recommendedViewportScale){const t=e.recommendedViewportScale;e.requestViewportScale(Math.max(t,.25))}const r=i.getBaseLayer();if(null!=r){const t=r instanceof XRWebGLLayer?r.getViewport(e):i.getBinding().getViewSubImage(r,e).viewport;this.threeRenderer.setViewport(t.x,t.y,t.width,t.height)}}placeInitially(){const e=this.presentedScene,{position:t,element:i}=e,n=e.getCamera(),{width:r,height:a}=this.overlay.getBoundingClientRect();e.setSize(r,a),n.projectionMatrixInverse.copy(n.projectionMatrix).invert();const{theta:o,radius:l}=i.getCameraOrbit(),c=n.getWorldDirection(Ec);e.yaw=Math.atan2(-c.x,-c.z)-o,this.goalYaw=e.yaw,t.copy(n.position).add(c.multiplyScalar(l)),this.updateTarget();const h=e.getTarget();t.add(h).sub(this.oldTarget),this.goalPosition.copy(t),e.setHotspotsVisibility(!0);const{session:d}=this.frame;d.addEventListener("selectstart",this.onSelectStart),d.addEventListener("selectend",this.onSelectEnd),d.requestHitTestSourceForTransientInput({profile:"generic-touchscreen"}).then((e=>{this.transientHitTestSource=e}))}getTouchLocation(){const{axes:e}=this.inputSource.gamepad;let t=this.placementBox.getExpandedHit(this.presentedScene,e[0],e[1]);return null!=t&&(Ec.copy(t).sub(this.presentedScene.getCamera().position),Ec.length()>10)?null:t}getHitPoint(e){const t=this.threeRenderer.xr.getReferenceSpace(),i=e.getPose(t);if(null==i)return null;const n=yc.fromArray(i.transform.matrix);return!0===this.placeOnWall&&(this.goalYaw=Math.atan2(n.elements[4],n.elements[6])),n.elements[5]>.75!==this.placeOnWall?_c.setFromMatrixPosition(n):null}moveToFloor(e){const t=this.initialHitSource;if(null==t)return;const i=e.getHitTestResults(t);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),t.cancel(),this.initialHitSource=null,this.dispatchEvent({type:"status",status:mc}))}fingerPolar(e){const t=e[0].inputSource.gamepad.axes,i=e[1].inputSource.gamepad.axes,n=i[0]-t[0],r=i[1]-t[1],a=Math.atan2(r,n);let o=this.lastAngle-a;return o>Math.PI?o-=2*Math.PI:o<-Math.PI&&(o+=2*Math.PI),this.lastAngle=a,{separation:Math.sqrt(n*n+r*r),deltaYaw:o}}processInput(e){const t=this.transientHitTestSource;if(null==t)return;if(!this.isTranslating&&!this.isTwoFingering&&!this.isRotating)return;const i=e.getHitTestResultsForTransientInput(t),n=this.presentedScene,r=n.scale.x;if(this.isTwoFingering)if(i.length<2)this.isTwoFingering=!1;else{const{separation:e,deltaYaw:t}=this.fingerPolar(i);if(!1===this.placeOnWall&&(this.goalYaw+=t),n.canScale){const t=e/this.firstRatio;this.goalScale=t<1.3&&t>dc?1:t}}else if(2!==i.length)if(this.isRotating){const e=1.5*this.inputSource.gamepad.axes[0];this.goalYaw+=e-this.lastAngle,this.lastAngle=e}else this.isTranslating&&i.forEach((e=>{if(e.inputSource!==this.inputSource)return;let t=null;if(e.results.length>0&&(t=this.getHitPoint(e.results[0])),null==t&&(t=this.getTouchLocation()),null!=t){if(this.goalPosition.sub(this.lastDragPosition),!1===this.placeOnWall){const e=t.y-this.lastDragPosition.y;if(e<0){this.placementBox.offsetHeight=e/r,this.presentedScene.setShadowOffset(e);const i=Ec.copy(n.getCamera().position),a=-e/(i.y-t.y);i.multiplyScalar(a),t.multiplyScalar(1-a).add(i)}}this.goalPosition.add(t),this.lastDragPosition.copy(t)}}));else{this.isTranslating=!1,this.isRotating=!1,this.isTwoFingering=!0;const{separation:e}=this.fingerPolar(i);this.firstRatio=e/r}}moveScene(e){const t=this.presentedScene,{position:i,yaw:n}=t,r=t.boundingSphere.radius,a=this.goalPosition,o=t.scale.x,l=this.placementBox;let c=uc.NONE;if(!a.equals(i)||this.goalScale!==o){c=uc.USER_INTERACTION;let{x:n,y:h,z:d}=i;n=this.xDamper.update(n,a.x,e,r),h=this.yDamper.update(h,a.y,e,r),d=this.zDamper.update(d,a.z,e,r),i.set(n,h,d);const A=this.scaleDamper.update(o,this.goalScale,e,1);if(t.scale.set(A,A,A),!this.isTranslating){const e=a.y-h;this.placementComplete&&!1===this.placeOnWall?(l.offsetHeight=e/A,t.setShadowOffset(e)):0===e&&(this.placementComplete=!0,l.show=!1,t.setShadowIntensity(.8))}}l.updateOpacity(e),t.updateTarget(e),t.yaw=this.yawDamper.update(n,this.goalYaw,e,Math.PI),t.element.dispatchEvent(new CustomEvent("camera-change",{detail:{source:c}}))}onWebXRFrame(e,t){this.frame=t,++this.frames;const i=this.threeRenderer.xr.getReferenceSpace(),n=t.getViewerPose(i);null==n&&!0===this.tracking&&this.frames>30&&(this.tracking=!1,this.dispatchEvent({type:"tracking",status:vc}));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:fc}));let a=!0;for(const i of n.views){if(this.updateView(i),a){this.moveToFloor(t),this.processInput(t);const i=e-this.lastTick;this.moveScene(i),this.renderer.preRender(r,e,i),this.lastTick=e,r.renderShadow(this.threeRenderer)}this.threeRenderer.render(r,r.getCamera()),a=!1}}}function clone(e){const t=new Map,i=new Map,n=e.clone();return parallelTraverse(e,n,(function(e,n){t.set(n,e),i.set(e,n)})),n.traverse((function(e){if(!e.isSkinnedMesh)return;const n=e,r=t.get(e),a=r.skeleton.bones;n.skeleton=r.skeleton.clone(),n.bindMatrix.copy(r.bindMatrix),n.skeleton.bones=a.map((function(e){return i.get(e)})),n.bind(n.skeleton,n.bindMatrix)})),n}function parallelTraverse(e,t,i){i(e,t);for(let n=0;n<e.children.length;n++)parallelTraverse(e.children[n],t.children[n],i)}
/* @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 Sc=Symbol("prepared"),Cc=Symbol("prepare"),Mc=Symbol("preparedGLTF"),bc=Symbol("clone");class GLTFInstance{constructor(e){this[Mc]=e}static prepare(e){if(null==e.scene)throw new Error("Model does not have a scene");if(e[Sc])return e;const t=this[Cc](e);return t[Sc]=!0,t}static[Cc](e){const{scene:t}=e,i=[t];return Object.assign(Object.assign({},e),{scene:t,scenes:i})}get parser(){return this[Mc].parser}get animations(){return this[Mc].animations}get scene(){return this[Mc].scene}get scenes(){return this[Mc].scenes}get cameras(){return this[Mc].cameras}get asset(){return this[Mc].asset}get userData(){return this[Mc].userData}clone(){return new(0,this.constructor)(this[bc]())}dispose(){this.scenes.forEach((e=>{e.traverse((e=>{const t=e;if(!t.material)return;(Array.isArray(t.material)?t.material:[t.material]).forEach((e=>{for(const t in e){const i=e[t];if(i instanceof Texture$1){const e=i.source.data;null!=e.close&&e.close(),i.dispose()}}e.dispose()})),t.geometry.dispose()}))}))}[bc](){const e=this[Mc],t=clone(this.scene);cloneVariantMaterials(t,this.scene);const i=[t],n=e.userData?Object.assign({},e.userData):{};return Object.assign(Object.assign({},e),{scene:t,scenes:i,userData:n})}}const cloneVariantMaterials=(e,t)=>{traversePair(e,t,((e,t)=>{void 0!==t.userData.variantMaterials&&(e.userData.variantMaterials=new Map(t.userData.variantMaterials)),void 0!==t.userData.variantData&&(e.userData.variantData=t.userData.variantData),void 0!==t.userData.originalMaterial&&(e.userData.originalMaterial=t.userData.originalMaterial)}))},traversePair=(e,t,i)=>{i(e,t);for(let n=0;n<e.children.length;n++)traversePair(e.children[n],t.children[n],i)},Ic=Symbol("threeGLTF"),wc=Symbol("gltf"),Tc=Symbol("gltfElementMap"),Bc=Symbol("threeObjectMap"),Rc=Symbol("parallelTraverseThreeScene"),Lc=Symbol("correlateOriginalThreeGLTF"),Dc=Symbol("correlateCloneThreeGLTF");class CorrelatedSceneGraph{constructor(e,t,i,n){this[Ic]=e,this[wc]=t,this[Tc]=n,this[Bc]=i}static from(e,t){return null!=t?this[Dc](e,t):this[Lc](e)}static[Lc](e){const t=e.parser.json,i=e.parser.associations,n=new Map,r={name:"Default"},a={type:"materials",index:-1};for(const e of i.keys())e instanceof Material$1&&null==i.get(e)&&(a.index<0&&(null==t.materials&&(t.materials=[]),a.index=t.materials.length,t.materials.push(r)),e.name=r.name,i.set(e,{materials:a.index}));for(const[e,r]of i){if(r){const t=e;t.userData=t.userData||{},t.userData.associations=r}for(const i in r)if(null!=i&&"primitives"!==i){const a=i,o=(t[a]||[])[r[a]];if(null==o)continue;let l=n.get(o);null==l&&(l=new Set,n.set(o,l)),l.add(e)}}return new CorrelatedSceneGraph(e,t,i,n)}static[Dc](e,t){const i=t.threeGLTF,n=t.gltf,r=JSON.parse(JSON.stringify(n)),a=new Map,o=new Map;for(let n=0;n<i.scenes.length;n++)this[Rc](i.scenes[n],e.scenes[n],((e,i)=>{const n=t.threeObjectMap.get(e);if(null!=n)for(const e in n)if(null!=e&&"primitives"!==e){const t=e,l=n[t],c=r[t][l],h=a.get(i)||{};h[t]=l,a.set(i,h);const d=o.get(c)||new Set;d.add(i),o.set(c,d)}}));return new CorrelatedSceneGraph(e,r,a,o)}static[Rc](e,t,i){const traverse=(e,t)=>{if(i(e,t),e.isObject3D){const n=e,r=t;if(n.material)if(Array.isArray(n.material))for(let e=0;e<n.material.length;++e)i(n.material[e],r.material[e]);else i(n.material,r.material);for(let i=0;i<e.children.length;++i)traverse(e.children[i],t.children[i])}};traverse(e,t)}get threeGLTF(){return this[Ic]}get gltf(){return this[wc]}get gltfElementMap(){return this[Tc]}get threeObjectMap(){return this[Bc]}}
/* @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 Uc=Symbol("correlatedSceneGraph");class ModelViewerGLTFInstance extends GLTFInstance{static[Cc](e){const t=super[Cc](e);null==t[Uc]&&(t[Uc]=CorrelatedSceneGraph.from(t));const{scene:i}=t,n=new Sphere(void 0,1/0);return i.traverse((e=>{e.renderOrder=1e3,e.frustumCulled=!1,e.name||(e.name=e.uuid);const i=e;if(i.material){const{geometry:e}=i;i.castShadow=!0,i.isSkinnedMesh&&(e.boundingSphere=n,e.boundingBox=null);const r=i.material;if(!0===r.isMeshBasicMaterial&&(r.toneMapped=!1),r.shadowSide=0,r.aoMap){const{gltf:i,threeObjectMap:n}=t[Uc],a=n.get(r);if(null!=i.materials&&null!=a&&null!=a.materials){const t=i.materials[a.materials];t.occlusionTexture&&0===t.occlusionTexture.texCoord&&null!=e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv)}}}})),t}get correlatedSceneGraph(){return this[Mc][Uc]}[bc](){const e=super[bc](),t=new Map;return e.scene.traverse((e=>{const i=e;if(i.material){const e=i.material;if(null!=e){if(t.has(e.uuid))return void(i.material=t.get(e.uuid));i.material=e.clone(),t.set(e.uuid,i.material)}}})),e[Uc]=CorrelatedSceneGraph.from(e,this.correlatedSceneGraph),e}}class RGBELoader extends DataTextureLoader{constructor(e){super(e),this.type=$}parse(e){const rgbe_error=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},fgets=function(e,t,i){t=t||1024;let n=e.pos,r=-1,a=0,o="",l=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));for(;0>(r=l.indexOf("\n"))&&a<t&&n<e.byteLength;)o+=l,a+=l.length,n+=128,l+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));return-1<r&&(!1!==i&&(e.pos+=a+r+1),o+l.slice(0,r))},RGBEByteToRGBFloat=function(e,t,i,n){const r=e[t+3],a=Math.pow(2,r-128)/255;i[n+0]=e[t+0]*a,i[n+1]=e[t+1]*a,i[n+2]=e[t+2]*a,i[n+3]=1},RGBEByteToRGBHalf=function(e,t,i,n){const r=e[t+3],a=Math.pow(2,r-128)/255;i[n+0]=pi.toHalfFloat(Math.min(e[t+0]*a,65504)),i[n+1]=pi.toHalfFloat(Math.min(e[t+1]*a,65504)),i[n+2]=pi.toHalfFloat(Math.min(e[t+2]*a,65504)),i[n+3]=pi.toHalfFloat(1)},t=new Uint8Array(e);t.pos=0;const i=function(e){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,i=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*FORMAT=(\S+)\s*$/,r=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,a={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let o,l;if(e.pos>=e.byteLength||!(o=fgets(e)))return rgbe_error(1,"no header found");if(!(l=o.match(/^#\?(\S+)/)))return rgbe_error(3,"bad initial token");for(a.valid|=1,a.programtype=l[1],a.string+=o+"\n";o=fgets(e),!1!==o;)if(a.string+=o+"\n","#"!==o.charAt(0)){if((l=o.match(t))&&(a.gamma=parseFloat(l[1])),(l=o.match(i))&&(a.exposure=parseFloat(l[1])),(l=o.match(n))&&(a.valid|=2,a.format=l[1]),(l=o.match(r))&&(a.valid|=4,a.height=parseInt(l[1],10),a.width=parseInt(l[2],10)),2&a.valid&&4&a.valid)break}else a.comments+=o+"\n";return 2&a.valid?4&a.valid?a:rgbe_error(3,"missing image size specifier"):rgbe_error(3,"missing format specifier")}(t);if(-1!==i){const e=i.width,n=i.height,r=function(e,t,i){const n=t;if(n<8||n>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(n!==(e[2]<<8|e[3]))return rgbe_error(3,"wrong scanline width");const r=new Uint8Array(4*t*i);if(!r.length)return rgbe_error(4,"unable to allocate buffer space");let a=0,o=0;const l=4*n,c=new Uint8Array(4),h=new Uint8Array(l);let d=i;for(;d>0&&o<e.byteLength;){if(o+4>e.byteLength)return rgbe_error(1);if(c[0]=e[o++],c[1]=e[o++],c[2]=e[o++],c[3]=e[o++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=n)return rgbe_error(3,"bad rgbe scanline format");let t,i=0;for(;i<l&&o<e.byteLength;){t=e[o++];const n=t>128;if(n&&(t-=128),0===t||i+t>l)return rgbe_error(3,"bad scanline data");if(n){const n=e[o++];for(let e=0;e<t;e++)h[i++]=n}else h.set(e.subarray(o,o+t),i),i+=t,o+=t}const A=n;for(let e=0;e<A;e++){let t=0;r[a]=h[e+t],t+=n,r[a+1]=h[e+t],t+=n,r[a+2]=h[e+t],t+=n,r[a+3]=h[e+t],a+=4}d--}return r}(t.subarray(t.pos),e,n);if(-1!==r){let t,a,o;switch(this.type){case K:o=r.length/4;const e=new Float32Array(4*o);for(let t=0;t<o;t++)RGBEByteToRGBFloat(r,4*t,e,4*t);t=e,a=K;break;case $:o=r.length/4;const i=new Uint16Array(4*o);for(let e=0;e<o;e++)RGBEByteToRGBHalf(r,4*e,i,4*e);t=i,a=$;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:i.string,gamma:i.gamma,exposure:i.exposure,type:a}}}return null}setDataType(e){return this.type=e,this}load(e,t,i,n){return super.load(e,(function onLoadCallback(e,i){switch(e.type){case K:case $:e.colorSpace=Ie,e.minFilter=O,e.magFilter=O,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,i)}),i,n)}}
/* @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.
 */class EnvironmentScene extends Scene{constructor(){super(),this.position.y=-3.5;const e=new BoxGeometry;e.deleteAttribute("uv");const t=new MeshStandardMaterial({metalness:0,side:1}),i=new MeshStandardMaterial({metalness:0}),n=new PointLight(16777215,500,28,2);n.position.set(.418,16.199,.3),this.add(n);const r=new Mesh(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const a=new Mesh(e,i);a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),this.add(a);const o=new Mesh(e,i);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const l=new Mesh(e,i);l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),this.add(l);const c=new Mesh(e,i);c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),this.add(c);const h=new Mesh(e,i);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const d=new Mesh(e,i);d.position.set(-2.193,-.369,-5.547),d.rotation.set(0,.516,0),d.scale.set(3.875,3.487,2.986),this.add(d);const A=new Mesh(e,this.createAreaLightMaterial(50));A.position.set(-16.116,14.37,8.208),A.scale.set(.1,2.428,2.739),this.add(A);const p=new Mesh(e,this.createAreaLightMaterial(50));p.position.set(-16.109,18.021,-8.207),p.scale.set(.1,2.425,2.751),this.add(p);const m=new Mesh(e,this.createAreaLightMaterial(17));m.position.set(14.904,12.198,-1.832),m.scale.set(.15,4.265,6.331),this.add(m);const g=new Mesh(e,this.createAreaLightMaterial(43));g.position.set(-.462,8.89,14.52),g.scale.set(4.38,5.441,.088),this.add(g);const f=new Mesh(e,this.createAreaLightMaterial(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,.1),this.add(f);const v=new Mesh(e,this.createAreaLightMaterial(100));v.position.set(0,20,0),v.scale.set(1,.1,1),this.add(v)}createAreaLightMaterial(e){const t=new MeshBasicMaterial;return t.color.setScalar(e),t}}
/* @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.
 */class EnvironmentSceneAlt extends Scene{constructor(){super(),this.position.y=-3.5;const e=new BoxGeometry;e.deleteAttribute("uv");const t=new MeshStandardMaterial({metalness:0,side:1}),i=new MeshStandardMaterial({metalness:0}),n=new PointLight(16777215,400,28,2);n.position.set(.5,14,.5),this.add(n);const r=new Mesh(e,t);r.position.set(0,13.2,0),r.scale.set(31.5,28.5,31.5),this.add(r);const a=new Mesh(e,i);a.position.set(-10.906,-1,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),this.add(a);const o=new Mesh(e,i);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const l=new Mesh(e,i);l.position.set(6.167,-.16,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),this.add(l);const c=new Mesh(e,i);c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),this.add(c);const h=new Mesh(e,i);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const d=new Mesh(e,i);d.position.set(-2.193,-.369,-5.547),d.rotation.set(0,.516,0),d.scale.set(3.875,3.487,2.986),this.add(d);const A=new Mesh(e,this.createAreaLightMaterial(80));A.position.set(-14,10,8),A.scale.set(.1,2.5,2.5),this.add(A);const p=new Mesh(e,this.createAreaLightMaterial(80));p.position.set(-14,14,-4),p.scale.set(.1,2.5,2.5),this.add(p);const m=new Mesh(e,this.createAreaLightMaterial(23));m.position.set(14,12,0),m.scale.set(.1,5,5),this.add(m);const g=new Mesh(e,this.createAreaLightMaterial(16));g.position.set(0,9,14),g.scale.set(5,5,.1),this.add(g);const f=new Mesh(e,this.createAreaLightMaterial(80));f.position.set(7,8,-14),f.scale.set(2.5,2.5,.1),this.add(f);const v=new Mesh(e,this.createAreaLightMaterial(80));v.position.set(-7,16,-14),v.scale.set(2.5,2.5,.1),this.add(v);const E=new Mesh(e,this.createAreaLightMaterial(1));E.position.set(0,20,0),E.scale.set(.1,.1,.1),this.add(E)}createAreaLightMaterial(e){const t=new MeshBasicMaterial;return t.color.setScalar(e),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.
 */const Pc=20,Fc=/\.hdr(\.js)?$/;class TextureUtils extends EventDispatcher{constructor(e){super(),this.threeRenderer=e,this.lottieLoaderUrl="",this.withCredentials=!1,this._ldrLoader=null,this._hdrLoader=null,this._lottieLoader=null,this.generatedEnvironmentMap=null,this.generatedEnvironmentMapAlt=null,this.skyboxCache=new Map,this.blurMaterial=null,this.blurScene=null}get ldrLoader(){return null==this._ldrLoader&&(this._ldrLoader=new TextureLoader),this._ldrLoader.setWithCredentials(this.withCredentials),this._ldrLoader}get hdrLoader(){return null==this._hdrLoader&&(this._hdrLoader=new RGBELoader,this._hdrLoader.setDataType($)),this._hdrLoader.setWithCredentials(this.withCredentials),this._hdrLoader}async getLottieLoader(){if(null==this._lottieLoader){const{LottieLoader:e}=await import(this.lottieLoaderUrl);this._lottieLoader=new e}return this._lottieLoader.setWithCredentials(this.withCredentials),this._lottieLoader}async loadImage(e){const t=await new Promise(((t,i)=>this.ldrLoader.load(e,t,(()=>{}),i)));return t.name=e,t.flipY=!1,t}async loadLottie(e,t){const i=await this.getLottieLoader();i.setQuality(t);const n=await new Promise(((t,n)=>i.load(e,t,(()=>{}),n)));return n.name=e,n}async loadEquirect(e,t=()=>{}){try{const i=Fc.test(e),n=i?this.hdrLoader:this.ldrLoader,r=await new Promise(((i,r)=>n.load(e,i,(e=>{t(e.loaded/e.total*.9)}),r)));return t(1),r.name=e,r.mapping=S,i||(r.encoding=Ce),r}finally{t&&t(1)}}async generateEnvironmentMapAndSkybox(e=null,t=null,i=()=>{}){const n="legacy"!==t;"legacy"!==t&&"neutral"!==t||(t=null),t=deserializeUrl(t);let r,a=Promise.resolve(null);e&&(a=this.loadEquirectFromUrl(e,i)),r=t?this.loadEquirectFromUrl(t,i):e?this.loadEquirectFromUrl(e,i):n?this.loadGeneratedEnvironmentMapAlt():this.loadGeneratedEnvironmentMap();const[o,l]=await Promise.all([r,a]);if(null==o)throw new Error("Failed to load environment map.");return{environmentMap:o,skybox:l}}async loadEquirectFromUrl(e,t){if(!this.skyboxCache.has(e)){const i=this.loadEquirect(e,t);this.skyboxCache.set(e,i)}return this.skyboxCache.get(e)}async GenerateEnvironmentMap(e,t){await((e=0)=>new Promise((t=>setTimeout(t,e))))();const i=this.threeRenderer,n=new WebGLCubeRenderTarget(256,{generateMipmaps:!1,type:$,format:ee,colorSpace:Ie,depthBuffer:!0}),r=new CubeCamera(.1,100,n),a=r.renderTarget.texture;a.name=t;const o=i.outputColorSpace,l=i.toneMapping;return i.toneMapping=0,i.outputColorSpace=Ie,r.update(i,e),this.blurCubemap(n,.04),i.toneMapping=l,i.outputColorSpace=o,a}async loadGeneratedEnvironmentMap(){return null==this.generatedEnvironmentMap&&(this.generatedEnvironmentMap=this.GenerateEnvironmentMap(new EnvironmentScene,"legacy")),this.generatedEnvironmentMap}async loadGeneratedEnvironmentMapAlt(){return null==this.generatedEnvironmentMapAlt&&(this.generatedEnvironmentMapAlt=this.GenerateEnvironmentMap(new EnvironmentSceneAlt,"neutral")),this.generatedEnvironmentMapAlt}blurCubemap(e,t){if(null==this.blurMaterial){this.blurMaterial=this.getBlurShader(Pc);const e=new BoxGeometry,t=new Mesh(e,this.blurMaterial);this.blurScene=new Scene,this.blurScene.add(t)}const i=e.clone();this.halfblur(e,i,t,"latitudinal"),this.halfblur(i,e,t,"longitudinal")}halfblur(e,t,i,n){const r=e.width,a=isFinite(i)?Math.PI/(2*r):2*Math.PI/39,o=i/a,l=isFinite(i)?1+Math.floor(3*o):Pc;l>Pc&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${l} samples when the maximum is set to 20`);const c=[];let h=0;for(let e=0;e<Pc;++e){const t=e/o,i=Math.exp(-t*t/2);c.push(i),0==e?h+=i:e<l&&(h+=2*i)}for(let e=0;e<c.length;e++)c[e]=c[e]/h;const d=this.blurMaterial.uniforms;d.envMap.value=e.texture,d.samples.value=l,d.weights.value=c,d.latitudinal.value="latitudinal"===n,d.dTheta.value=a;new CubeCamera(.1,100,t).update(this.threeRenderer,this.blurScene)}getBlurShader(e){const t=new Float32Array(e),i=new Vector3(0,1,0);return new ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:e},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:t},latitudinal:{value:!1},dTheta:{value:0},poleAxis:{value:i}},vertexShader:"\n      \n      varying vec3 vOutputDirection;\n  \n      void main() {\n  \n        vOutputDirection = vec3( position );\n        gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n  \n      }\n    ",fragmentShader:"\n        varying vec3 vOutputDirection;\n  \n        uniform samplerCube envMap;\n        uniform int samples;\n        uniform float weights[ n ];\n        uniform bool latitudinal;\n        uniform float dTheta;\n        uniform vec3 poleAxis;\n  \n        vec3 getSample( float theta, vec3 axis ) {\n  \n          float cosTheta = cos( theta );\n          // Rodrigues' axis-angle rotation\n          vec3 sampleDirection = vOutputDirection * cosTheta\n            + cross( axis, vOutputDirection ) * sin( theta )\n            + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n  \n          return vec3( textureCube( envMap, sampleDirection ) );\n  \n        }\n  \n        void main() {\n  \n          vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n  \n          if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n  \n            axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n  \n          }\n  \n          axis = normalize( axis );\n  \n          gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n          gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n  \n          for ( int i = 1; i < n; i++ ) {\n  \n            if ( i >= 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:1})}async dispose(){for(const[,e]of this.skyboxCache){(await e).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 Nc=[1,.79,.62,.5,.4,.31,.25],Qc="high-performance";class Renderer extends EventDispatcher{constructor(e){super(),this.loader=new CachingGLTFLoader(ModelViewerGLTFInstance),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=e=>{this.dispatchEvent({type:"contextlost",sourceEvent:e})},this.onWebGLContextRestored=()=>{var e;null===(e=this.textureUtils)||void 0===e||e.dispose(),this.textureUtils=new TextureUtils(this.threeRenderer);for(const e of this.scenes)e.element[Ns]()},this.dpr=Ds(),this.canvas3D=document.createElement("canvas"),this.canvas3D.id="webgl-canvas",this.canvas3D.classList.add("show");try{this.threeRenderer=new WebGLRenderer({canvas:this.canvas3D,alpha:!0,antialias:!0,powerPreference:e.powerPreference,preserveDrawingBuffer:!0}),this.threeRenderer.autoClear=!0,this.threeRenderer.useLegacyLights=!1,this.threeRenderer.setPixelRatio(1),this.threeRenderer.debug={checkShaderErrors:!!e.debug,onShaderError:null},this.threeRenderer.toneMapping=4}catch(e){console.warn(e)}this.arRenderer=new ARRenderer(this),this.textureUtils=this.canRender?new TextureUtils(this.threeRenderer):null,CachingGLTFLoader.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 e=this._singleton.dispose();for(const t of e)t.disconnectedCallback();this._singleton=new Renderer({powerPreference:(self.ModelViewerElement||{}).powerPreference||Qc,debug:Us()});for(const t of e)t.connectedCallback()}get canRender(){return null!=this.threeRenderer}get scaleFactor(){return Nc[this.scaleStep]}set minScale(e){let t=1;for(;t<Nc.length&&!(Nc[t]<e);)++t;this.lastStep=t-1}registerScene(e){this.scenes.add(e),e.forceRescale();const t=new Vector2;this.threeRenderer.getSize(t),e.canvas.width=t.x,e.canvas.height=t.y,this.canRender&&this.scenes.size>0&&this.threeRenderer.setAnimationLoop(((e,t)=>this.render(e,t)))}unregisterScene(e){this.scenes.delete(e),this.canvas3D.parentElement===e.canvas.parentElement&&e.canvas.parentElement.removeChild(this.canvas3D),this.canRender&&0===this.scenes.size&&this.threeRenderer.setAnimationLoop(null)}displayCanvas(e){return this.multipleScenesVisible?e.element[rd]:this.canvas3D}countVisibleScenes(){const{canvas3D:e}=this;let t=0,i=null;for(const n of this.scenes){const{element:r}=n;r.modelIsVisible&&null==n.externalRenderer&&++t,e.parentElement===n.canvas.parentElement&&(i=n)}const n=t>1;if(null!=i){const t=n&&!this.multipleScenesVisible,r=!i.element.modelIsVisible;if(t||r){const{width:t,height:n}=this.sceneSize(i);this.copyPixels(i,t,n),e.parentElement.removeChild(e)}}this.multipleScenesVisible=n}updateRendererSize(){var e;const t=Ds();if(t!==this.dpr)for(const e of this.scenes){const{element:t}=e;t[Wu](t.getBoundingClientRect())}let i=0,n=0;for(const e of this.scenes)i=Math.max(i,e.width),n=Math.max(n,e.height);if(i!==this.width||n!==this.height||t!==this.dpr){this.width=i,this.height=n,this.dpr=t,i=Math.ceil(i*t),n=Math.ceil(n*t),this.canRender&&this.threeRenderer.setSize(i,n,!1);for(const t of this.scenes){const{canvas:r}=t;r.width=i,r.height=n,t.forceRescale(),null===(e=t.effectRenderer)||void 0===e||e.setSize(i,n)}}}updateRendererScale(e){const t=this.scaleStep;this.avgFrameDuration+=clamp(.2*(e-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),t!==this.scaleStep&&(this.avgFrameDuration=50)}shouldRender(e){if(e.shouldRender())e.scaleStep!=this.scaleStep&&(e.scaleStep=this.scaleStep,this.rescaleCanvas(e));else{if(0==e.scaleStep)return!1;e.scaleStep=0,this.rescaleCanvas(e)}return!0}rescaleCanvas(e){const t=Nc[e.scaleStep],i=Math.ceil(this.width/t),n=Math.ceil(this.height/t),{style:r}=e.canvas;r.width=`${i}px`,r.height=`${n}px`,this.canvas3D.style.width=`${i}px`,this.canvas3D.style.height=`${n}px`;const a=this.dpr*t,o=t<1?"GPU throttling":this.dpr!==window.devicePixelRatio?"No meta viewport tag":"";e.element.dispatchEvent(new CustomEvent("render-scale",{detail:{reportedDpr:window.devicePixelRatio,renderedDpr:a,minimumDpr:this.dpr*Nc[this.lastStep],pixelWidth:Math.ceil(e.width*a),pixelHeight:Math.ceil(e.height*a),reason:o}}))}sceneSize(e){const{dpr:t}=this,i=Nc[e.scaleStep];return{width:Math.min(Math.ceil(e.width*i*t),this.canvas3D.width),height:Math.min(Math.ceil(e.height*i*t),this.canvas3D.height)}}copyPixels(e,t,i){const n=e.context;null!=n?(n.clearRect(0,0,t,i),n.drawImage(this.canvas3D,0,0,t,i,0,0,t,i),e.canvas.classList.add("show")):console.log("could not acquire 2d context")}orderedScenes(){const e=[];for(const t of[!1,!0])for(const i of this.scenes)i.element.modelIsVisible===t&&e.push(i);return e}get isPresenting(){return this.arRenderer.isPresenting}preRender(e,t,i){const{element:n,exposure:r}=e;n[od](t,i);const a="number"==typeof r&&!Number.isNaN(r);this.threeRenderer.toneMappingExposure=a?r:1}render(e,t){if(null!=t)return void this.arRenderer.onWebXRFrame(e,t);const i=e-this.lastTick;if(this.lastTick=e,!this.canRender||this.isPresenting)return;this.countVisibleScenes(),this.updateRendererSize(),this.renderedLastFrame&&(this.updateRendererScale(i),this.renderedLastFrame=!1);const{canvas3D:n}=this;for(const t of this.orderedScenes()){const{element:r}=t;if(!r.loaded||!r.modelIsVisible&&t.renderCount>0)continue;if(this.preRender(t,e,i),!this.shouldRender(t))continue;if(null!=t.externalRenderer){const e=t.getCamera();e.updateMatrix();const{matrix:i,projectionMatrix:n}=e,r=i.elements.slice(),a=t.getTarget();r[12]+=a.x,r[13]+=a.y,r[14]+=a.z,t.externalRenderer.render({viewMatrix:r,projectionMatrix:n.elements});continue}if(!r.modelIsVisible&&!this.multipleScenesVisible)for(const e of this.scenes)e.element.modelIsVisible&&e.queueRender();const{width:a,height:o}=this.sceneSize(t);t.renderShadow(this.threeRenderer),this.threeRenderer.setRenderTarget(null),this.threeRenderer.setViewport(0,Math.ceil(this.height*this.dpr)-o,a,o),null!=t.effectRenderer?t.effectRenderer.render(i):(this.threeRenderer.autoClear=!0,this.threeRenderer.render(t,t.camera)),this.multipleScenesVisible||!t.element.modelIsVisible&&0===t.renderCount?this.copyPixels(t,a,o):n.parentElement!==t.canvas.parentElement&&(t.canvas.parentElement.appendChild(n),t.canvas.classList.remove("show")),t.hasRendered(),++t.renderCount,this.renderedLastFrame=!0}}dispose(){null!=this.textureUtils&&this.textureUtils.dispose(),null!=this.threeRenderer&&this.threeRenderer.dispose(),this.textureUtils=null,this.threeRenderer=null;const e=[];for(const t of this.scenes)e.push(t.element);return this.canvas3D.removeEventListener("webglcontextlost",this.onWebGLContextLost),this.canvas3D.removeEventListener("webglcontextrestored",this.onWebGLContextRestored),e}}Renderer._singleton=new Renderer({powerPreference:(self.ModelViewerElement||{}).powerPreference||Qc,debug:Us()});
/* @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 Oc=Symbol("correlatedObjects"),kc=Symbol("onUpdate");class ThreeDOMElement{constructor(e,t=null){this[kc]=e,this[Oc]=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.
 */const Gc=new MeshBasicMaterial,Vc=new PlaneGeometry(2,2);let Hc=0;const zc=Symbol("threeTexture"),Wc=Symbol("threeTextures");class Image$1 extends ThreeDOMElement{get[zc](){var e;return null===(e=this[Oc])||void 0===e?void 0:e.values().next().value}get[Wc](){return this[Oc]}constructor(e,t){super(e,new Set(t?[t]:[])),this[zc].image.src||(this[zc].image.src="adhoc_image"+Hc++),this[zc].image.name||(this[zc].image.name=t&&t.image&&t.image.src?t.image.src.split("/").pop():"adhoc_image")}get name(){return this[zc].image.name||""}get uri(){return this[zc].image.src}get bufferView(){return this[zc].image.bufferView}get element(){const e=this[zc];if(e&&(e.isCanvasTexture||e.isVideoTexture))return e.image}get animation(){const e=this[zc];if(e&&e.isCanvasTexture&&e.animation)return e.animation}get type(){return null!=this.uri?"external":"embedded"}set name(e){for(const t of this[Wc])t.image.name=e}update(){const e=this[zc];e&&e.isCanvasTexture&&!e.animation&&(this[zc].needsUpdate=!0,this[kc]())}async createThumbnail(e,t){const i=new Scene;Gc.map=this[zc];const n=new Mesh(Vc,Gc);i.add(n);const r=new OrthographicCamera(-1,1,1,-1,0,1),{threeRenderer:a}=Renderer.singleton,o=new WebGLRenderTarget(e,t);a.setRenderTarget(o),a.render(i,r),a.setRenderTarget(null);const l=new Uint8Array(e*t*4);a.readRenderTargetPixels(o,0,0,e,t,l),Pu.width=e,Pu.height=t;const c=Pu.getContext("2d"),h=c.createImageData(e,t);return h.data.set(l),c.putImageData(h,0,0),new Promise((async(e,t)=>{Pu.toBlob((i=>{if(!i)return t("Failed to capture thumbnail.");e(URL.createObjectURL(i))}),"image/png")}))}}var qc,Xc;!function(e){e[e.Nearest=9728]="Nearest",e[e.Linear=9729]="Linear",e[e.NearestMipmapNearest=9984]="NearestMipmapNearest",e[e.LinearMipmapNearest=9985]="LinearMipmapNearest",e[e.NearestMipmapLinear=9986]="NearestMipmapLinear",e[e.LinearMipmapLinear=9987]="LinearMipmapLinear"}(qc||(qc={})),function(e){e[e.ClampToEdge=33071]="ClampToEdge",e[e.MirroredRepeat=33648]="MirroredRepeat",e[e.Repeat=10497]="Repeat"}(Xc||(Xc={}));
/* @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 jc=(()=>{const e=[qc.Nearest,qc.Linear,qc.NearestMipmapNearest,qc.LinearMipmapLinear,qc.NearestMipmapLinear,qc.LinearMipmapLinear];return t=>e.indexOf(t)>-1})(),Yc=(()=>{const e=[qc.Nearest,qc.Linear];return t=>e.indexOf(t)>-1})(),Kc=(()=>{const e=[Xc.ClampToEdge,Xc.MirroredRepeat,Xc.Repeat];return t=>e.indexOf(t)>-1})(),$c=Symbol("threeTexture"),Jc=Symbol("threeTextures"),Zc=Symbol("setProperty");class Sampler extends ThreeDOMElement{get[$c](){var e;return null===(e=this[Oc])||void 0===e?void 0:e.values().next().value}get[Jc](){return this[Oc]}constructor(e,t){super(e,new Set(t?[t]:[]))}get name(){return this[$c].name||""}get minFilter(){return this[$c].minFilter}get magFilter(){return this[$c].magFilter}get wrapS(){return this[$c].wrapS}get wrapT(){return this[$c].wrapT}get rotation(){return this[$c].rotation}get scale(){return this[$c].repeat}get offset(){return this[$c].offset}setMinFilter(e){this[Zc]("minFilter",e)}setMagFilter(e){this[Zc]("magFilter",e)}setWrapS(e){this[Zc]("wrapS",e)}setWrapT(e){this[Zc]("wrapT",e)}setRotation(e){null==e&&(e=0),this[Zc]("rotation",e)}setScale(e){null==e&&(e=new Vector2(1,1)),this[Zc]("repeat",e)}setOffset(e){null==e&&(e=new Vector2(0,0)),this[Zc]("offset",e)}[Zc](e,t){if(((e,t)=>{switch(e){case"minFilter":return jc(t);case"magFilter":return Yc(t);case"wrapS":case"wrapT":return Kc(t);case"rotation":case"repeat":case"offset":return!0;default:throw new Error(`Cannot configure property "${e}" on Sampler`)}})(e,t))for(const i of this[Jc])i[e]=t,i.needsUpdate=!0;this[kc]()}}
/* @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 eh=Symbol("image"),th=Symbol("sampler"),ih=Symbol("threeTexture");class Texture extends ThreeDOMElement{constructor(e,t){super(e,new Set(t?[t]:[])),this[th]=new Sampler(e,t),this[eh]=new Image$1(e,t)}get[ih](){var e;return null===(e=this[Oc])||void 0===e?void 0:e.values().next().value}get name(){return this[ih].name||""}set name(e){for(const t of this[Oc])t.name=e}get sampler(){return this[th]}get source(){return this[eh]}}
/* @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 nh,rh,sh;const ah=Symbol("texture"),oh=Symbol("transform"),lh=Symbol("materials"),ch=Symbol("usage"),hh=Symbol("onUpdate"),uh=Symbol("activeVideo");var dh;!function(e){e[e.Base=0]="Base",e[e.MetallicRoughness=1]="MetallicRoughness",e[e.Normal=2]="Normal",e[e.Occlusion=3]="Occlusion",e[e.Emissive=4]="Emissive",e[e.Clearcoat=5]="Clearcoat",e[e.ClearcoatRoughness=6]="ClearcoatRoughness",e[e.ClearcoatNormal=7]="ClearcoatNormal",e[e.SheenColor=8]="SheenColor",e[e.SheenRoughness=9]="SheenRoughness",e[e.Transmission=10]="Transmission",e[e.Thickness=11]="Thickness",e[e.Specular=12]="Specular",e[e.SpecularColor=13]="SpecularColor",e[e.Iridescence=14]="Iridescence",e[e.IridescenceThickness=15]="IridescenceThickness",e[e.Anisotropy=16]="Anisotropy"}(dh||(dh={}));class TextureInfo{constructor(e,t,i,n){this[nh]=null,this[rh]={rotation:0,scale:new Vector2(1,1),offset:new Vector2(0,0)},this[sh]=!1,i&&(this[oh].rotation=i.rotation,this[oh].scale.copy(i.repeat),this[oh].offset.copy(i.offset),this[ah]=new Texture(e,i)),this[hh]=e,this[lh]=n,this[ch]=t}get texture(){return this[ah]}setTexture(e){var t,i;const n=null!=e?e.source[zc]:null,r=null===(t=this[ah])||void 0===t?void 0:t.source[zc];if(null!=r&&r.isVideoTexture?this[uh]=!1:(null===(i=this[ah])||void 0===i?void 0:i.source.animation)&&this[ah].source.animation.removeEventListener("enterFrame",this[hh]),this[ah]=e,null!=n&&n.isVideoTexture){const e=n.image;if(this[uh]=!0,null!=e.requestVideoFrameCallback){const update=()=>{this[uh]&&(this[hh](),e.requestVideoFrameCallback(update))};e.requestVideoFrameCallback(update)}else{const update=()=>{this[uh]&&(this[hh](),requestAnimationFrame(update))};requestAnimationFrame(update)}}else null!=(null==e?void 0:e.source.animation)&&e.source.animation.addEventListener("enterFrame",this[hh]);let a=be;if(this[lh])for(const e of this[lh]){switch(this[ch]){case dh.Base:e.map=n;break;case dh.MetallicRoughness:a=Ie,e.metalnessMap=n,e.roughnessMap=n;break;case dh.Normal:a=Ie,e.normalMap=n;break;case dh.Occlusion:a=Ie,e.aoMap=n;break;case dh.Emissive:e.emissiveMap=n;break;case dh.Clearcoat:e.clearcoatMap=n;break;case dh.ClearcoatRoughness:e.clearcoatRoughnessMap=n;break;case dh.ClearcoatNormal:e.clearcoatNormalMap=n;break;case dh.SheenColor:e.sheenColorMap=n;break;case dh.SheenRoughness:e.sheenRoughnessMap=n;break;case dh.Transmission:e.transmissionMap=n;break;case dh.Thickness:e.thicknessMap=n;break;case dh.Specular:e.specularIntensityMap=n;break;case dh.SpecularColor:e.specularColorMap=n;break;case dh.Iridescence:e.iridescenceMap=n;break;case dh.IridescenceThickness:e.iridescenceThicknessMap=n;break;case dh.Anisotropy:e.anisotropyMap=n}e.needsUpdate=!0}n&&(n.colorSpace=a,n.rotation=this[oh].rotation,n.repeat=this[oh].scale,n.offset=this[oh].offset),this[hh]()}}nh=ah,rh=oh,sh=uh;
/* @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 Ah=Symbol("threeMaterial"),ph=Symbol("threeMaterials"),mh=Symbol("baseColorTexture"),gh=Symbol("metallicRoughnessTexture");class PBRMetallicRoughness extends ThreeDOMElement{constructor(e,t){super(e,t);const{map:i,metalnessMap:n}=t.values().next().value;this[mh]=new TextureInfo(e,dh.Base,i,t),this[gh]=new TextureInfo(e,dh.MetallicRoughness,n,t)}get[ph](){return this[Oc]}get[Ah](){var e;return null===(e=this[Oc])||void 0===e?void 0:e.values().next().value}get baseColorFactor(){const e=[0,0,0,this[Ah].opacity];return this[Ah].color.toArray(e),e}get metallicFactor(){return this[Ah].metalness}get roughnessFactor(){return this[Ah].roughness}get baseColorTexture(){return this[mh]}get metallicRoughnessTexture(){return this[gh]}setBaseColorFactor(e){const t=new Color;e instanceof Array?t.fromArray(e):t.set(e);for(const i of this[ph])i.color.set(t),e instanceof Array?i.opacity=e[3]:(e=[0,0,0,i.opacity],t.toArray(e));this[kc]()}setMetallicFactor(e){for(const t of this[ph])t.metalness=e;this[kc]()}setRoughnessFactor(e){for(const t of this[ph])t.roughness=e;this[kc]()}}
/* @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 fh,vh;const Eh=Symbol("pbrMetallicRoughness"),yh=Symbol("normalTexture"),_h=Symbol("occlusionTexture"),xh=Symbol("emissiveTexture"),Sh=Symbol("backingThreeMaterial"),Ch=Symbol("applyAlphaCutoff"),Mh=Symbol("getAlphaMode"),bh=Symbol("lazyLoadGLTFInfo"),Ih=Symbol("initialize"),wh=Symbol("getLoadedMaterial"),Th=Symbol("ensureMaterialIsLoaded"),Bh=Symbol("gltfIndex"),Rh=Symbol("setActive"),Lh=Symbol("variantIndices"),Dh=Symbol("isActive"),Uh=Symbol("variantSet"),Ph=Symbol("modelVariants"),Fh=Symbol("name"),Nh=Symbol("pbrTextures");class Material extends ThreeDOMElement{constructor(e,t,i,n,r,a,o=void 0){super(e,r),this[fh]=new Set,this[vh]=new Map,this[Bh]=t,this[Dh]=i,this[Ph]=n,this[Fh]=a,null==o?this[Ih]():this[bh]=o}get[(fh=Uh,vh=Nh,Sh)](){return this[Oc].values().next().value}[Ih](){const e=this[kc],t=this[Oc];this[Eh]=new PBRMetallicRoughness(e,t);const{normalMap:i,aoMap:n,emissiveMap:r}=t.values().next().value;this[yh]=new TextureInfo(e,dh.Normal,i,t),this[_h]=new TextureInfo(e,dh.Occlusion,n,t),this[xh]=new TextureInfo(e,dh.Emissive,r,t);const createTextureInfo=i=>{this[Nh].set(i,new TextureInfo(e,i,null,t))};createTextureInfo(dh.Clearcoat),createTextureInfo(dh.ClearcoatRoughness),createTextureInfo(dh.ClearcoatNormal),createTextureInfo(dh.SheenColor),createTextureInfo(dh.SheenRoughness),createTextureInfo(dh.Transmission),createTextureInfo(dh.Thickness),createTextureInfo(dh.Specular),createTextureInfo(dh.SpecularColor),createTextureInfo(dh.Iridescence),createTextureInfo(dh.IridescenceThickness),createTextureInfo(dh.Anisotropy)}async[wh](){if(null!=this[bh]){const{set:e,material:t}=await this[bh].doLazyLoad();return this[Oc]=e,this[Ih](),this[bh]=void 0,this.ensureLoaded=async()=>{},t}return this[Oc].values().next().value}colorFromRgb(e){const t=new Color;return e instanceof Array?t.fromArray(e):t.set(e),t}[Th](){if(null!=this[bh])throw new Error(`Material "${this.name}" has not been loaded, call 'await\n    myMaterial.ensureLoaded()' before using an unloaded material.`)}async ensureLoaded(){await this[wh]()}get isLoaded(){return null==this[bh]}get isActive(){return this[Dh]}[Rh](e){this[Dh]=e}get name(){return this[Fh]||""}set name(e){if(this[Fh]=e,null!=this[Oc])for(const t of this[Oc])t.name=e}get pbrMetallicRoughness(){return this[Th](),this[Eh]}get normalTexture(){return this[Th](),this[yh]}get occlusionTexture(){return this[Th](),this[_h]}get emissiveTexture(){return this[Th](),this[xh]}get emissiveFactor(){return this[Th](),this[Sh].emissive.toArray()}get index(){return this[Bh]}[Lh](){return this[Uh]}hasVariant(e){const t=this[Ph].get(e);return null!=t&&this[Uh].has(t.index)}setEmissiveFactor(e){this[Th]();const t=this.colorFromRgb(e);for(const e of this[Oc])e.emissive.set(t);this[kc]()}[Mh](){return this[Sh].transparent?"BLEND":this[Sh].alphaTest>0?"MASK":"OPAQUE"}[Ch](){this[Th]();for(const e of this[Oc])"MASK"===this[Mh]()?null==e.alphaTest&&(e.alphaTest=.5):e.alphaTest=void 0,e.needsUpdate=!0}setAlphaCutoff(e){this[Th]();for(const t of this[Oc])t.alphaTest=e,t.needsUpdate=!0;this[Ch](),this[kc]()}getAlphaCutoff(){return this[Th](),this[Sh].alphaTest}setDoubleSided(e){this[Th]();for(const t of this[Oc])t.side=e?2:0,t.needsUpdate=!0;this[kc]()}getDoubleSided(){return this[Th](),2==this[Sh].side}setAlphaMode(e){this[Th]();const enableTransparency=(e,t)=>{e.transparent=t,e.depthWrite=!t};for(const t of this[Oc])enableTransparency(t,"BLEND"===e),t.alphaTest="MASK"===e?.5:void 0,t.needsUpdate=!0;this[kc]()}getAlphaMode(){return this[Th](),this[Mh]()}get emissiveStrength(){return this[Th](),this[Sh].emissiveIntensity}setEmissiveStrength(e){this[Th]();for(const t of this[Oc])t.emissiveIntensity=e;this[kc]()}get clearcoatFactor(){return this[Th](),this[Sh].clearcoat}get clearcoatRoughnessFactor(){return this[Th](),this[Sh].clearcoatRoughness}get clearcoatTexture(){return this[Th](),this[Nh].get(dh.Clearcoat)}get clearcoatRoughnessTexture(){return this[Th](),this[Nh].get(dh.ClearcoatRoughness)}get clearcoatNormalTexture(){return this[Th](),this[Nh].get(dh.ClearcoatNormal)}get clearcoatNormalScale(){return this[Th](),this[Sh].clearcoatNormalScale.x}setClearcoatFactor(e){this[Th]();for(const t of this[Oc])t.clearcoat=e;this[kc]()}setClearcoatRoughnessFactor(e){this[Th]();for(const t of this[Oc])t.clearcoatRoughness=e;this[kc]()}setClearcoatNormalScale(e){this[Th]();for(const t of this[Oc])t.clearcoatNormalScale=new Vector2(e,e);this[kc]()}get ior(){return this[Th](),this[Sh].ior}setIor(e){this[Th]();for(const t of this[Oc])t.ior=e;this[kc]()}get sheenColorFactor(){return this[Th](),this[Sh].sheenColor.toArray()}get sheenColorTexture(){return this[Th](),this[Nh].get(dh.SheenColor)}get sheenRoughnessFactor(){return this[Th](),this[Sh].sheenRoughness}get sheenRoughnessTexture(){return this[Th](),this[Nh].get(dh.SheenRoughness)}setSheenColorFactor(e){this[Th]();const t=this.colorFromRgb(e);for(const e of this[Oc])e.sheenColor.set(t),e.sheen=1;this[kc]()}setSheenRoughnessFactor(e){this[Th]();for(const t of this[Oc])t.sheenRoughness=e,t.sheen=1;this[kc]()}get transmissionFactor(){return this[Th](),this[Sh].transmission}get transmissionTexture(){return this[Th](),this[Nh].get(dh.Transmission)}setTransmissionFactor(e){this[Th]();for(const t of this[Oc])t.transmission=e;this[kc]()}get thicknessFactor(){return this[Th](),this[Sh].thickness}get thicknessTexture(){return this[Th](),this[Nh].get(dh.Thickness)}get attenuationDistance(){return this[Th](),this[Sh].attenuationDistance}get attenuationColor(){return this[Th](),this[Sh].attenuationColor.toArray()}setThicknessFactor(e){this[Th]();for(const t of this[Oc])t.thickness=e;this[kc]()}setAttenuationDistance(e){this[Th]();for(const t of this[Oc])t.attenuationDistance=e;this[kc]()}setAttenuationColor(e){this[Th]();const t=this.colorFromRgb(e);for(const e of this[Oc])e.attenuationColor.set(t);this[kc]()}get specularFactor(){return this[Th](),this[Sh].specularIntensity}get specularTexture(){return this[Th](),this[Nh].get(dh.Specular)}get specularColorFactor(){return this[Th](),this[Sh].specularColor.toArray()}get specularColorTexture(){return this[Th](),this[Nh].get(dh.SheenColor)}setSpecularFactor(e){this[Th]();for(const t of this[Oc])t.specularIntensity=e;this[kc]()}setSpecularColorFactor(e){this[Th]();const t=this.colorFromRgb(e);for(const e of this[Oc])e.specularColor.set(t);this[kc]()}get iridescenceFactor(){return this[Th](),this[Sh].iridescence}get iridescenceTexture(){return this[Th](),this[Nh].get(dh.Iridescence)}get iridescenceIor(){return this[Th](),this[Sh].iridescenceIOR}get iridescenceThicknessMinimum(){return this[Th](),this[Sh].iridescenceThicknessRange[0]}get iridescenceThicknessMaximum(){return this[Th](),this[Sh].iridescenceThicknessRange[1]}get iridescenceThicknessTexture(){return this[Th](),this[Nh].get(dh.IridescenceThickness)}setIridescenceFactor(e){this[Th]();for(const t of this[Oc])t.iridescence=e;this[kc]()}setIridescenceIor(e){this[Th]();for(const t of this[Oc])t.iridescenceIOR=e;this[kc]()}setIridescenceThicknessMinimum(e){this[Th]();for(const t of this[Oc])t.iridescenceThicknessRange[0]=e;this[kc]()}setIridescenceThicknessMaximum(e){this[Th]();for(const t of this[Oc])t.iridescenceThicknessRange[1]=e;this[kc]()}get anisotropyStrength(){return this[Th](),this[Sh].anisotropy}get anisotropyRotation(){return this[Th](),this[Sh].anisotropyRotation}get anisotropyTexture(){return this[Th](),this[Nh].get(dh.Anisotropy)}setAnisotropyStrength(e){this[Th]();for(const t of this[Oc])t.anisotropy=e;this[kc]()}setAnisotropyRotation(e){this[Th]();for(const t of this[Oc])t.anisotropyRotation=e;this[kc]()}}class Node$1{constructor(e){this.name="",this.children=new Array,this.name=e}}class PrimitiveNode extends Node$1{constructor(e,t,i,n){super(e.name),this.materials=new Map,this.variantToMaterialMap=new Map,this.initialMaterialIdx=0,this.activeMaterialIdx=0,this.mesh=e;const{gltf:r,threeGLTF:a,threeObjectMap:o}=n;this.modelVariants=i,this.mesh.userData.variantData=i;const l=o.get(e.material);null!=l.materials?this.initialMaterialIdx=this.activeMaterialIdx=l.materials:console.error(`Primitive (${e.name}) missing initial material reference.`);const c=e.userData.associations||{};if(null==c.meshes)return void console.error("Mesh is missing primitive index association");const h=((r.meshes||[])[c.meshes].primitives||[])[c.primitives];if(null!=h){if(null!=h.material)this.materials.set(h.material,t[h.material]);else{const e=t.findIndex((e=>"Default"===e.name));e>=0?this.materials.set(e,t[e]):console.warn("gltfPrimitive has no material!")}if(h.extensions&&h.extensions.KHR_materials_variants){const e=h.extensions.KHR_materials_variants,n=a.parser.json.extensions.KHR_materials_variants.variants;for(const r of e.mappings){const e=t[r.material];this.materials.set(r.material,e);for(const t of r.variants){const{name:r}=n[t];this.variantToMaterialMap.set(t,e),e[Lh]().add(t),i.has(r)||i.set(r,{name:r,index:t})}}}}else console.error("Mesh primitive definition is missing.")}async setActiveMaterial(e){const t=this.materials.get(e);return null!=t&&(this.mesh.material=await t[wh](),this.activeMaterialIdx=e),this.mesh.material}getActiveMaterial(){return this.materials.get(this.activeMaterialIdx)}getMaterial(e){return this.materials.get(e)}async enableVariant(e){if(null==e)return this.setActiveMaterial(this.initialMaterialIdx);if(null!=this.variantToMaterialMap&&this.modelVariants.has(e)){const t=this.modelVariants.get(e);return this.enableVariantHelper(t.index)}return null}async enableVariantHelper(e){if(null!=this.variantToMaterialMap&&null!=e){const t=this.variantToMaterialMap.get(e);if(null!=t)return this.setActiveMaterial(t.index)}return null}async instantiateVariants(){if(null!=this.variantToMaterialMap)for(const e of this.variantToMaterialMap.keys()){const t=this.mesh.userData.variantMaterials.get(e);if(null!=t.material)continue;const i=await this.enableVariantHelper(e);null!=i&&(t.material=i)}}get variantInfo(){return this.variantToMaterialMap}addVariant(e,t){if(!this.ensureVariantIsUnused(t))return!1;this.modelVariants.has(t)||this.modelVariants.set(t,{name:t,index:this.modelVariants.size});const i=this.modelVariants.get(t).index;return e[Lh]().add(i),this.variantToMaterialMap.set(i,e),this.materials.set(e.index,e),this.updateVariantUserData(i,e),!0}deleteVariant(e){if(this.variantInfo.has(e)){this.variantInfo.delete(e);const t=this.mesh.userData.variantMaterials;null!=t&&t.delete(e)}}updateVariantUserData(e,t){t[Lh]().add(e),this.mesh.userData.variantData=this.modelVariants,this.mesh.userData.variantMaterials=this.mesh.userData.variantMaterials||new Map;this.mesh.userData.variantMaterials.set(e,{material:t[Oc].values().next().value,gltfMaterialIndex:t.index})}ensureVariantIsUnused(e){const t=this.modelVariants.get(e);return null==t||!this.variantInfo.has(t.index)||(console.warn(`Primitive cannot add variant '${e}' 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 Qh,Oh,kh,Gh,Vh,Hh;const zh=Symbol("materials"),Wh=Symbol("hierarchy"),qh=Symbol("roots"),Xh=Symbol("primitives"),jh=Symbol("prepareVariantsForExport"),Yh=Symbol("switchVariant"),Kh=Symbol("materialFromPoint"),$h=Symbol("nodeFromPoint"),Jh=Symbol("nodeFromIndex"),Zh=Symbol("variantData"),eu=Symbol("availableVariants"),tu=Symbol("modelOnUpdate"),iu=Symbol("cloneMaterial");class LazyLoader{constructor(e,t,i,n){this.gltf=e,this.gltfElementMap=t,this.mapKey=i,this.doLazyLoad=n}}class Model{constructor(e,t=()=>{}){this[Qh]=new Array,this[Oh]=new Array,this[kh]=new Array,this[Gh]=new Array,this[Vh]=()=>{},this[Hh]=new Map,this[tu]=t;const{gltf:i,threeGLTF:n,gltfElementMap:r}=e;for(const[e,a]of i.materials.entries()){const o=r.get(a);if(null!=o)this[zh].push(new Material(t,e,!0,this[Zh],o,a.name));else{const l=(i.materials||[])[e],c=e,materialLoadCallback=async()=>{const e=await n.parser.getDependency("material",c),t=new Set;return r.set(l,t),t.add(e),{set:t,material:e}};this[zh].push(new Material(t,e,!1,this[Zh],o,a.name,new LazyLoader(i,r,l,materialLoadCallback)))}}const a=new Map,o=new Array;for(const e of n.scene.children)o.push(e);for(;o.length>0;){const t=o.pop();let i=null;t instanceof Mesh?(i=new PrimitiveNode(t,this.materials,this[Zh],e),this[Xh].push(i)):i=new Node$1(t.name);const n=a.get(t);null!=n?n.children.push(i):this[qh].push(i),this[Wh].push(i);for(const e of t.children)o.push(e),a.set(t,i)}}get materials(){return this[zh]}[(Qh=zh,Oh=Wh,kh=qh,Gh=Xh,Vh=tu,Hh=Zh,eu)](){const e=Array.from(this[Zh].values());return e.sort(((e,t)=>e.index-t.index)),e.map((e=>e.name))}getMaterialByName(e){const t=this[zh].filter((t=>t.name===e));return t.length>0?t[0]:null}[Jh](e,t){const i=this[Wh].find((i=>{if(i instanceof PrimitiveNode){const{meshes:n,primitives:r}=i.mesh.userData.associations;if(n==e&&r==t)return!0}return!1}));return null==i?null:i}[$h](e){return this[Wh].find((t=>{if(t instanceof PrimitiveNode){if(t.mesh===e.object)return!0}return!1}))}[Kh](e){return this[$h](e).getActiveMaterial()}async[Yh](e){for(const t of this[Xh])await t.enableVariant(e);for(const e of this.materials)e[Rh](!1);for(const e of this[Xh])this.materials[e.getActiveMaterial().index][Rh](!0)}async[jh](){const e=new Array;for(const t of this[Xh])e.push(t.instantiateVariants());await Promise.all(e)}[iu](e,t){const i=this.materials[e];i.isLoaded||console.error("Cloning an unloaded material,\n           call 'material.ensureLoaded() before cloning the material.");const n=i[Oc],r=new Set;for(const[e,i]of n.entries()){const a=i.clone();a.name=t+(n.size>1?"_inst"+e:""),r.add(a)}const a=new Material(this[tu],this[zh].length,!1,this[Zh],r,t);return this[zh].push(a),a}createMaterialInstanceForVariant(e,t,i,n=!0){let r=null;for(const n of this[Xh]){const a=this[Zh].get(i);null!=a&&n.variantInfo.has(a.index)||null!=n.getMaterial(e)&&(this.hasVariant(i)||this.createVariant(i),null==r&&(r=this[iu](e,t)),n.addVariant(r,i))}if(n&&null!=r){r[Rh](!0),this.materials[e][Rh](!1);for(const e of this[Xh])e.enableVariant(i)}return r}createVariant(e){this[Zh].has(e)?console.warn(`Variant '${e}'' already exists`):this[Zh].set(e,{name:e,index:this[Zh].size})}hasVariant(e){return this[Zh].has(e)}setMaterialToVariant(e,t){if(null!=this[eu]().find((e=>e===t)))if(e<0||e>=this.materials.length)console.error("setMaterialToVariant(): materialIndex is out of bounds.");else for(const i of this[Xh]){const n=i.getMaterial(e);null!=n&&i.addVariant(n,t)}else console.warn(`Can't add material to '${t}', the variant does not exist.'`)}updateVariantName(e,t){const i=this[Zh].get(e);null!=i&&(i.name=t,this[Zh].set(t,i),this[Zh].delete(e))}deleteVariant(e){const t=this[Zh].get(e);if(null!=t){for(const i of this.materials)i.hasVariant(e)&&i[Uh].delete(t.index);for(const e of this[Xh])e.deleteVariant(t.index);this[Zh].delete(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.
 */var __decorate$5=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};const nu=Symbol("currentGLTF"),ru=Symbol("originalGltfJson"),su=Symbol("model"),au=Symbol("getOnUpdateMethod"),ou=Symbol("buildTexture"),lu=new Vector3,cu=new Vector3,hu=new Vector3,uu=new Matrix3,du=new Triangle,Au=new Quaternion;class Hotspot extends CSS2DObject{constructor(e){super(document.createElement("div")),this.normal=new Vector3(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=e.name,this.element.appendChild(this.pivot),this.pivot.appendChild(this.slot),this.updatePosition(e.position),this.updateNormal(e.normal),this.surface=e.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(e){if(null==e)return;const t=Po(e)[0].terms;for(let e=0;e<3;++e)this.position.setComponent(e,Vo(t[e]).number);this.updateMatrixWorld()}updateNormal(e){if(null==e)return;const t=Po(e)[0].terms;for(let e=0;e<3;++e)this.normal.setComponent(e,t[e].number)}updateSurface(e){if(!e&&this.initialized)return;const{mesh:t,tri:i,bary:n}=this;if(null==t||null==i||null==n)return;t.getVertexPosition(i.x,lu),t.getVertexPosition(i.y,cu),t.getVertexPosition(i.z,hu),lu.toArray(uu.elements,0),cu.toArray(uu.elements,3),hu.toArray(uu.elements,6),this.position.copy(n).applyMatrix3(uu);const r=this.parent;r.worldToLocal(t.localToWorld(this.position)),du.set(lu,cu,hu),du.getNormal(this.normal).transformDirection(t.matrixWorld);const a=r.parent;Au.setFromAxisAngle(lu.set(0,1,0),-a.yaw),this.normal.applyQuaternion(Au)}orient(e){this.pivot.style.transform=`rotate(${e}rad)`}updateVisibility(e){e?this.element.classList.remove("hide"):this.element.classList.add("hide"),this.slot.assignedNodes().forEach((t=>{if(t.nodeType!==Node.ELEMENT_NODE)return;const i=t,n=i.dataset.visibilityAttribute;if(null!=n){const t=`data-${n}`;e?i.setAttribute(t,""):i.removeAttribute(t)}i.dispatchEvent(new CustomEvent("hotspot-visibility",{detail:{visible:e}}))})),this.initialized=!0}}const pu={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}"},mu={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 lerp(e,t,i){return(1-i)*e+i*t}
/* @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 Shadow extends Object3D{constructor(e,t,i){super(),this.camera=new OrthographicCamera,this.renderTarget=null,this.renderTargetBlur=null,this.depthMaterial=new MeshDepthMaterial,this.horizontalBlurMaterial=new ShaderMaterial(pu),this.verticalBlurMaterial=new ShaderMaterial(mu),this.intensity=0,this.softness=1,this.boundingBox=new Box3,this.size=new Vector3,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 PlaneGeometry,a=new MeshBasicMaterial({opacity:1,transparent:!0,side:1});this.floor=new Mesh(r,a),this.floor.userData.shadow=!0,n.add(this.floor),this.blurPlane=new Mesh(r),this.blurPlane.visible=!1,n.add(this.blurPlane),e.target.add(this),this.depthMaterial.onBeforeCompile=function(e){e.fragmentShader=e.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(e,t,i)}setScene(e,t,i){const{boundingBox:n,size:r,rotation:a,position:o}=this;if(this.isAnimated=e.animationNames.length>0,this.boundingBox.copy(e.boundingBox),this.size.copy(e.size),this.maxDimension=Math.max(r.x,r.y,r.z)*(this.isAnimated?2:1),this.boundingBox.getCenter(o),"back"===i){const{min:e,max:t}=n;[e.y,e.z]=[e.z,e.y],[t.y,t.z]=[t.z,t.y],[r.y,r.z]=[r.z,r.y],a.x=Math.PI/2,a.y=Math.PI}else a.x=0,a.y=0;if(this.isAnimated){const e=n.min.y,t=n.max.y;r.y=this.maxDimension,n.expandByVector(r.subScalar(this.maxDimension).multiplyScalar(-.5)),n.min.y=e,n.max.y=t,r.set(this.maxDimension,t-e,this.maxDimension)}"bottom"===i?o.y=n.min.y:o.z=n.min.y,this.setSoftness(t)}setSoftness(e){this.softness=e;const{size:t,camera:i}=this,n=this.isAnimated?2:1,r=n*Math.pow(2,9-3*e);this.setMapSize(r);const a=t.y/2,o=t.y*n;i.near=0,i.far=lerp(o,a,e),this.depthMaterial.opacity=1/e,i.updateProjectionMatrix(),this.setIntensity(this.intensity),this.setOffset(0)}setMapSize(e){const{size:t}=this;this.isAnimated&&(e*=2);const i=Math.floor(t.x>t.z?e:e*t.x/t.z),n=Math.floor(t.x>t.z?e*t.z/t.x:e),r=10+i,a=10+n;if(null==this.renderTarget||this.renderTarget.width===r&&this.renderTarget.height===a||(this.renderTarget.dispose(),this.renderTarget=null,this.renderTargetBlur.dispose(),this.renderTargetBlur=null),null==this.renderTarget){const e={format:ee};this.renderTarget=new WebGLRenderTarget(r,a,e),this.renderTargetBlur=new WebGLRenderTarget(r,a,e),this.floor.material.map=this.renderTarget.texture}this.camera.scale.set(t.x*(1+10/i),t.z*(1+10/n),1),this.needsUpdate=!0}setIntensity(e){this.intensity=e,e>0?(this.visible=!0,this.floor.visible=!0,this.floor.material.opacity=e*lerp(.3,1,this.softness*this.softness)):(this.visible=!1,this.floor.visible=!1)}getIntensity(){return this.intensity}setOffset(e){this.floor.position.z=-e+.001*this.maxDimension}render(e,t){t.overrideMaterial=this.depthMaterial;const i=e.getClearAlpha();e.setClearAlpha(0),this.floor.visible=!1;const n=e.xr.enabled;e.xr.enabled=!1;const r=e.getRenderTarget();e.setRenderTarget(this.renderTarget),e.render(t,this.camera),t.overrideMaterial=null,this.floor.visible=!0,this.blurShadow(e),e.xr.enabled=n,e.setRenderTarget(r),e.setClearAlpha(i)}blurShadow(e){const{camera:t,horizontalBlurMaterial:i,verticalBlurMaterial:n,renderTarget:r,renderTargetBlur:a,blurPlane:o}=this;o.visible=!0,o.material=i,i.uniforms.h.value=1/this.renderTarget.width,i.uniforms.tDiffuse.value=this.renderTarget.texture,e.setRenderTarget(a),e.render(o,t),o.material=n,n.uniforms.v.value=1/this.renderTarget.height,n.uniforms.tDiffuse.value=this.renderTargetBlur.texture,e.setRenderTarget(r),e.render(o,t),o.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 gu=new Vector3,fu=new Vector3,vu=new Vector3,Eu=new class Raycaster{constructor(e,t,i=0,n=1/0){this.ray=new Ray(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new Layers,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return intersectObject(e,this,i,t),i.sort(ascSort),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)intersectObject(e[n],this,i,t);return i.sort(ascSort),i}},yu=new Vector3,_u=new Vector2;class ModelScene extends Scene{constructor({canvas:e,element:t,width:i,height:n}){super(),this.annotationRenderer=new CSS2DRenderer,this.effectRenderer=null,this.schemaElement=document.createElement("script"),this.width=1,this.height=1,this.aspect=1,this.scaleStep=0,this.renderCount=0,this.externalRenderer=null,this.camera=new PerspectiveCamera(45,1,.1,100),this.xrCamera=null,this.url=null,this.target=new Object3D,this.animationNames=[],this.boundingBox=new Box3,this.boundingSphere=new Sphere,this.size=new Vector3,this.idealAspect=0,this.framedFoVDeg=0,this.shadow=null,this.shadowIntensity=0,this.shadowSoftness=1,this.bakedShadows=new Set,this.exposure=1,this.canScale=!0,this.isDirty=!1,this.goalTarget=new Vector3,this.targetDamperX=new Damper,this.targetDamperY=new Damper,this.targetDamperZ=new Damper,this._currentGLTF=null,this._model=null,this.cancelPendingSourceChange=null,this.animationsByName=new Map,this.currentAnimationAction=null,this.name="ModelScene",this.element=t,this.canvas=e,this.camera=new PerspectiveCamera(45,1,.1,100),this.camera.name="MainCamera",this.add(this.target),this.setSize(i,n),this.target.name="Target",this.mixer=new AnimationMixer(this.target);const{domElement:r}=this.annotationRenderer,{style:a}=r;a.display="none",a.pointerEvents="none",a.position="absolute",a.top="0",this.element.shadowRoot.querySelector(".default").appendChild(r),this.schemaElement.setAttribute("type","application/ld+json")}get context(){return this.canvas.getContext("2d")}getCamera(){return null!=this.xrCamera?this.xrCamera:this.camera}queueRender(){this.isDirty=!0}shouldRender(){return this.isDirty}hasRendered(){this.isDirty=!1}forceRescale(){this.scaleStep=-1,this.queueRender()}async setObject(e){this.reset(),this._model=e,this.target.add(e),await this.setupScene()}async setSource(e,t=()=>{}){if(!e||e===this.url)return void t(1);if(this.reset(),this.url=e,null!=this.externalRenderer){const e=await this.externalRenderer.load(t);return this.boundingSphere.radius=e.framedRadius,void(this.idealAspect=e.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[hd].loader.load(e,this.element,t))}catch(e){n(e)}}))}catch(e){if(null==e)return;throw e}this.cancelPendingSourceChange=null,this.reset(),this.url=e,this._currentGLTF=i,null!=i&&(this._model=i.scene,this.target.add(i.scene));const{animations:n}=i,r=new Map,a=[];for(const e of n)r.set(e.name,e),a.push(e.name);this.animations=n,this.animationsByName=r,this.animationNames=a,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:e}=this;null!=e&&(e.removeFromParent(),this._model=null);const t=this._currentGLTF;null!=t&&(t.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[nu]=null,this.element[ru]=null,this.element[su]=null}get currentGLTF(){return this._currentGLTF}setSize(e,t){if(this.width!==e||this.height!==t){if(this.width=Math.max(e,1),this.height=Math.max(t,1),this.annotationRenderer.setSize(e,t),this.aspect=this.width/this.height,null!=this.externalRenderer){const i=Ds();this.externalRenderer.resize(e*i,t*i)}this.queueRender()}}markBakedShadow(e){e.userData.shadow=!0,this.bakedShadows.add(e)}unmarkBakedShadow(e){e.userData.shadow=!1,e.visible=!0,this.bakedShadows.delete(e),this.boundingBox.expandByObject(e)}findBakedShadows(e){const t=new Box3;e.traverse((e=>{const i=e;if(!i.material)return;if(!i.material.transparent)return;t.setFromObject(i);const n=t.getSize(yu),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:e,max:t}=this.boundingBox,i=new Box3;this.boundingBox.getSize(this.size);for(const n of this.bakedShadows)i.setFromObject(n),i.min.y<e.y+this.size.y/100&&i.min.x<=e.x&&i.max.x>=t.x&&i.min.z<=e.z&&i.max.z>=t.z||i.min.z<e.z+this.size.z/100&&i.min.x<=e.x&&i.max.x>=t.x&&i.min.y<=e.y&&i.max.y>=t.y||this.unmarkBakedShadow(n)}applyTransform(){const{model:e}=this;if(null==e)return;const t=Po(this.element.orientation)[0].terms,i=Vo(t[0]).number,n=Vo(t[1]).number,r=Vo(t[2]).number;e.quaternion.setFromEuler(new Euler(n,r,i,"YXZ"));const a=Po(this.element.scale)[0].terms;e.scale.set(a[0].number,a[1].number,a[2].number)}updateBoundingBox(){const{model:e}=this;if(null==e)return;this.target.remove(e),this.findBakedShadows(e);const bound=(e,t)=>e.expandByPoint(t);this.setBakedShadowVisibility(!1),this.boundingBox=reduceVertices(e,bound,new Box3),this.boundingBox.isEmpty()&&(this.setBakedShadowVisibility(!0),this.bakedShadows.forEach((e=>this.unmarkBakedShadow(e))),this.boundingBox=reduceVertices(e,bound,new Box3)),this.checkBakedShadows(),this.setBakedShadowVisibility(),this.boundingBox.getSize(this.size),this.target.add(e)}async updateFraming(){const{model:e}=this;if(null==e)return;this.target.remove(e),this.setBakedShadowVisibility(!1);const{center:t}=this.boundingSphere;this.element.requestUpdate("cameraTarget"),await this.element.updateComplete,t.copy(this.getTarget());this.boundingSphere.radius=Math.sqrt(reduceVertices(e,((e,i)=>Math.max(e,t.distanceToSquared(i))),0));this.idealAspect=reduceVertices(e,((e,i)=>{i.sub(t);const n=Math.sqrt(i.x*i.x+i.z*i.z);return Math.max(e,n/(this.idealCameraDistance()-Math.abs(i.y)))}),0)/Math.tan(this.framedFoVDeg/2*Math.PI/180),this.setBakedShadowVisibility(),this.target.add(e)}setBakedShadowVisibility(e=this.shadowIntensity<=0){for(const t of this.bakedShadows)t.visible=e}idealCameraDistance(){const e=this.framedFoVDeg/2*Math.PI/180;return this.boundingSphere.radius/Math.sin(e)}adjustedFoV(e){const t=Math.tan(e/2*Math.PI/180)*Math.max(1,this.idealAspect/this.aspect);return 2*Math.atan(t)*180/Math.PI}getNDC(e,t){if(null!=this.xrCamera)_u.set(e/window.screen.width,t/window.screen.height);else{const i=this.element.getBoundingClientRect();_u.set((e-i.x)/this.width,(t-i.y)/this.height)}return _u.multiplyScalar(2).subScalar(1),_u.y*=-1,_u}getSize(){return{width:this.width,height:this.height}}setEnvironmentAndSkybox(e,t){this.element[hd].arRenderer.presentedScene!==this&&(this.environment=e,this.background=t,this.queueRender())}setTarget(e,t,i){this.goalTarget.set(-e,-t,-i)}setTargetDamperDecayTime(e){this.targetDamperX.setDecayTime(e),this.targetDamperY.setDecayTime(e),this.targetDamperZ.setDecayTime(e)}getTarget(){return this.goalTarget.clone().multiplyScalar(-1)}jumpToGoal(){this.updateTarget(1e4)}updateTarget(e){const t=this.goalTarget,i=this.target.position;if(t.equals(i))return!1;{const n=this.boundingSphere.radius/10;let{x:r,y:a,z:o}=i;return r=this.targetDamperX.update(r,t.x,e,n),a=this.targetDamperY.update(a,t.y,e,n),o=this.targetDamperZ.update(o,t.z,e,n),this.target.position.set(r,a,o),this.target.updateMatrixWorld(),this.queueRender(),!0}}pointTowards(e,t){const{x:i,z:n}=this.position;this.yaw=Math.atan2(e-i,t-n)}get model(){return this._model}set yaw(e){this.rotation.y=e,this.queueRender()}get yaw(){return this.rotation.y}set animationTime(e){this.mixer.setTime(e),this.queueShadowRender()}get animationTime(){if(null!=this.currentAnimationAction){const e=Math.max(this.currentAnimationAction._loopCount,0);return this.currentAnimationAction.loop!==ge||1&~e?this.currentAnimationAction.time:this.duration-this.currentAnimationAction.time}return 0}set animationTimeScale(e){this.mixer.timeScale=e}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(e=null,t=0,i=2201,n=1/0){if(null==this._currentGLTF)return;const{animations:r}=this;if(null==r||0===r.length)return;let a=null;if(null!=e&&(a=this.animationsByName.get(e),null==a)){const t=parseInt(e);!isNaN(t)&&t>=0&&t<r.length&&(a=r[t])}null==a&&(a=r[0]);try{const{currentAnimationAction:e}=this,r=this.mixer.clipAction(a,this);this.currentAnimationAction=r,this.element.paused?this.mixer.stopAllAction():(r.paused=!1,null!=e&&r!==e?r.crossFadeFrom(e,t,!1):this.animationTimeScale>0&&this.animationTime==this.duration&&(this.animationTime=0)),r.setLoop(i,n),r.enabled=!0,r.clampWhenFinished=!0,r.play()}catch(e){console.error(e)}}stopAnimation(){this.currentAnimationAction=null,this.mixer.stopAllAction()}updateAnimation(e){this.mixer.update(e),this.queueShadowRender()}subscribeMixerEvent(e,t){this.mixer.addEventListener(e,t)}updateShadow(){const e=this.shadow;if(null!=e){const t="wall"===this.element.arPlacement?"back":"bottom";e.setScene(this,this.shadowSoftness,t),e.needsUpdate=!0}}renderShadow(e){const t=this.shadow;null!=t&&1==t.needsUpdate&&(t.render(e,this),t.needsUpdate=!1)}queueShadowRender(){null!=this.shadow&&(this.shadow.needsUpdate=!0)}setShadowIntensity(e){if(this.shadowIntensity=e,null!=this._currentGLTF&&(this.setBakedShadowVisibility(),!(e<=0&&null==this.shadow))){if(null==this.shadow){const e="wall"===this.element.arPlacement?"back":"bottom";this.shadow=new Shadow(this,this.shadowSoftness,e)}this.shadow.setIntensity(e)}}setShadowSoftness(e){this.shadowSoftness=e;const t=this.shadow;null!=t&&t.setSoftness(e)}setShadowOffset(e){const t=this.shadow;null!=t&&t.setOffset(e)}hitFromPoint(e,t=this){Eu.setFromCamera(e,this.getCamera());return Eu.intersectObject(t,!0).find((e=>e.object.visible&&!e.object.userData.shadow))}positionAndNormalFromPoint(e,t=this){var i;const n=this.hitFromPoint(e,t);if(null==n)return null;return{position:n.point,normal:null!=n.face?n.face.normal.clone().applyNormalMatrix((new Matrix3).getNormalMatrix(n.object.matrixWorld)):Eu.ray.direction.clone().multiplyScalar(-1),uv:null!==(i=n.uv)&&void 0!==i?i:null}}surfaceFromPoint(e,t=this){const i=this.element.model;if(null==i)return null;const n=this.hitFromPoint(e,t);if(null==n||null==n.face)return null;const r=i[$h](n),{meshes:a,primitives:o}=r.mesh.userData.associations,l=new Vector3,c=new Vector3,h=new Vector3,{a:d,b:A,c:p}=n.face,m=n.object;m.getVertexPosition(d,l),m.getVertexPosition(A,c),m.getVertexPosition(p,h);const g=new Triangle(l,c,h),f=new Vector3;return g.getBarycoord(m.worldToLocal(n.point),f),`${a} ${o} ${d} ${A} ${p} ${f.x.toFixed(3)} ${f.y.toFixed(3)} ${f.z.toFixed(3)}`}addHotspot(e){this.target.add(e),this.annotationRenderer.domElement.appendChild(e.element)}removeHotspot(e){this.target.remove(e)}forHotspots(e){const{children:t}=this.target;for(let i=0,n=t.length;i<n;i++){const n=t[i];n instanceof Hotspot&&e(n)}}initializeSurface(e){if(null!=e.surface&&null==e.mesh){const t=Po(e.surface)[0].terms;if(8!=t.length)return void console.warn(e.surface+" does not have exactly 8 numbers.");const i=this.element.model[Jh](t[0].number,t[1].number),n=new Vector3(t[2].number,t[3].number,t[4].number);if(null==i)return void console.warn(e.surface+" does not match a node/primitive in this glTF! Skipping this hotspot.");const r=i.mesh.geometry.attributes.position.count;if(n.x>=r||n.y>=r||n.z>=r)return void console.warn(e.surface+" vertex indices out of range in this glTF! Skipping this hotspot.");const a=new Vector3(t[5].number,t[6].number,t[7].number);e.mesh=i.mesh,e.tri=n,e.bary=a}}updateSurfaceHotspots(){const e=!this.element.paused;this.forHotspots((t=>{this.initializeSurface(t),t.updateSurface(e)}))}updateHotspotsVisibility(e){this.forHotspots((t=>{gu.copy(e),fu.setFromMatrixPosition(t.matrixWorld),gu.sub(fu),vu.copy(t.normal).transformDirection(this.target.matrixWorld),gu.dot(vu)<0?t.hide():t.show()}))}orientHotspots(e){this.forHotspots((t=>{t.orient(e)}))}setHotspotsVisibility(e){this.forHotspots((t=>{t.visible=e}))}updateSchema(e){var t;const{schemaElement:i,element:n}=this,{alt:r,poster:a,iosSrc:o}=n;if(null!=e){const n=[{"@type":"MediaObject",contentUrl:e,encodingFormat:"gltf"===(null===(t=e.split(".").pop())||void 0===t?void 0:t.toLowerCase())?"model/gltf+json":"model/gltf-binary"}];o&&n.push({"@type":"MediaObject",contentUrl:o,encodingFormat:"model/vnd.usdz+zip"});const l={"@context":"http://schema.org/","@type":"3DModel",image:null!=a?a:void 0,name:null!=r?r:void 0,encoding:n};i.textContent=JSON.stringify(l),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 ProgressTracker extends EventTarget{constructor(){super(...arguments),this.ongoingActivities=new Set,this.totalProgress=0}get ongoingActivityCount(){return this.ongoingActivities.size}beginActivity(){const e={progress:0,completed:!1};return this.ongoingActivities.add(e),1===this.ongoingActivityCount&&this.announceTotalProgress(e,0),t=>{let i;return i=Math.max(clamp(t,0,1),e.progress),i!==e.progress&&this.announceTotalProgress(e,i),e.progress}}announceTotalProgress(e,t){let i=0,n=0;1==t&&(e.completed=!0);for(const e of this.ongoingActivities){const{progress:t}=e;i+=1-t,!0===e.completed&&n++}const r=e.progress;e.progress=t,this.totalProgress+=(t-r)*(1-this.totalProgress)/i;const a=n===this.ongoingActivityCount?1:this.totalProgress;this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:a}})),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 xu,Su,Cu,Mu,bu,Iu,wu,Tu,Bu,Ru,Lu,Du,Uu,__decorate$4=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};const Pu=document.createElement("canvas"),Fu=Symbol("fallbackResizeHandler"),Nu=Symbol("defaultAriaLabel"),Qu=Symbol("resizeObserver"),Ou=Symbol("clearModelTimeout"),ku=Symbol("onContextLost"),Gu=Symbol("loaded"),Vu=Symbol("status"),Hu=Symbol("onFocus"),zu=Symbol("onBlur"),Wu=Symbol("updateSize"),qu=Symbol("intersectionObserver"),Xu=Symbol("isElementInViewport"),ju=Symbol("announceModelVisibility"),Yu=Symbol("ariaLabel"),Ku=Symbol("altDefaulted"),$u=Symbol("statusElement"),Ju=Symbol("updateStatus"),Zu=Symbol("loadedTime"),ed=Symbol("updateSource"),td=Symbol("markLoaded"),id=Symbol("container"),nd=Symbol("input"),rd=Symbol("canvas"),sd=Symbol("scene"),ad=Symbol("needsRender"),od=Symbol("tick"),ld=Symbol("onModelLoad"),cd=Symbol("onResize"),hd=Symbol("renderer"),ud=Symbol("progressTracker"),dd=Symbol("getLoaded"),Ad=Symbol("getModelIsVisible"),pd=Symbol("shouldAttemptPreload"),toVector3D=e=>({x:e.x,y:e.y,z:e.z,toString(){return`${this.x}m ${this.y}m ${this.z}m`}}),toVector2D=e=>({u:e.x,v:e.y,toString(){return`${this.u} ${this.v}`}});class ModelViewerElementBase extends u{constructor(){super(),this.alt=null,this.src=null,this.withCredentials=!1,this.generateSchema=!1,this[xu]=!1,this[Su]=!1,this[Cu]=0,this[Mu]="",this[bu]=null,this[Iu]=debounce((()=>{const e=this.getBoundingClientRect();this[Wu](e)}),50),this[wu]=debounce((e=>{const t=this.modelIsVisible;t!==e&&this.dispatchEvent(new CustomEvent("model-visibility",{detail:{visible:t}}))}),0),this[Tu]=null,this[Bu]=null,this[Ru]=new ProgressTracker,this[Lu]=()=>{this[$u].textContent=this[Vu]},this[Du]=()=>{this[$u].textContent=""},this[Uu]=e=>{this.dispatchEvent(new CustomEvent("error",{detail:{type:"webglcontextlost",sourceError:e.sourceEvent}}))},this.attachShadow({mode:"open"});const e=this.shadowRoot;let t,i;if((e=>{D(Os,e)})(e),this[id]=e.querySelector(".container"),this[nd]=e.querySelector(".userInput"),this[rd]=e.querySelector("canvas"),this[$u]=e.querySelector("#status"),this[Nu]=this[nd].getAttribute("aria-label"),this.isConnected){const e=this.getBoundingClientRect();t=e.width,i=e.height}else t=300,i=150;this[sd]=new ModelScene({canvas:this[rd],element:this,width:t,height:i}),Promise.resolve().then((()=>{this[Wu](this.getBoundingClientRect())})),Ss&&(this[Qu]=new ResizeObserver((e=>{if(!this[hd].isPresenting)for(let t of e)t.target===this&&this[Wu](t.contentRect)}))),Cs?this[qu]=new IntersectionObserver((e=>{for(let t of e)if(t.target===this){const e=this.modelIsVisible;this[Xu]=t.isIntersecting,this[ju](e),this[Xu]&&!this.loaded&&this[ed]()}}),{root:null,rootMargin:"0px",threshold:1e-5}):this[Xu]=!0}static get is(){return"model-viewer"}static set modelCacheSize(e){CachingGLTFLoader[qa].evictionThreshold=e}static get modelCacheSize(){return CachingGLTFLoader[qa].evictionThreshold}static set minimumRenderScale(e){e>1&&console.warn("<model-viewer> minimumRenderScale has been clamped to a maximum value of 1."),e<=0&&console.warn("<model-viewer> minimumRenderScale has been clamped to a minimum value of 0.25."),Renderer.singleton.minScale=e}static get minimumRenderScale(){return Renderer.singleton.minScale}get loaded(){return this[dd]()}get[(xu=Xu,Su=Gu,Cu=Zu,Mu=Vu,bu=Ou,Iu=Fu,wu=ju,Tu=Qu,Bu=qu,Ru=ud,hd)](){return Renderer.singleton}get modelIsVisible(){return this[Ad]()}connectedCallback(){super.connectedCallback&&super.connectedCallback(),Ss?this[Qu].observe(this):self.addEventListener("resize",this[Fu]),Cs&&this[qu].observe(this),this.addEventListener("focus",this[Hu]),this.addEventListener("blur",this[zu]);const e=this[hd];e.addEventListener("contextlost",this[ku]),e.registerScene(this[sd]),null!=this[Ou]&&(self.clearTimeout(this[Ou]),this[Ou]=null,this.requestUpdate("src",null))}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),Ss?this[Qu].unobserve(this):self.removeEventListener("resize",this[Fu]),Cs&&this[qu].unobserve(this),this.removeEventListener("focus",this[Hu]),this.removeEventListener("blur",this[zu]);const e=this[hd];e.removeEventListener("contextlost",this[ku]),e.unregisterScene(this[sd]),this[Ou]=self.setTimeout((()=>{this[sd].dispose(),this[Ou]=null}),10)}updated(e){super.updated(e),e.has("src")&&(null==this.src?(this[Gu]=!1,this[Zu]=0,this[sd].reset()):this.src!==this[sd].url&&(this[Gu]=!1,this[Zu]=0,this[ed]())),e.has("alt")&&this[nd].setAttribute("aria-label",this[Yu]),e.has("withCredentials")&&(CachingGLTFLoader.withCredentials=this.withCredentials,this[hd].textureUtils.withCredentials=this.withCredentials),e.has("generateSchema")&&(this.generateSchema?this[sd].updateSchema(this.src):this[sd].updateSchema(null))}toDataURL(e,t){return this[hd].displayCanvas(this[sd]).toDataURL(e,t)}async toBlob(e){const t=e?e.mimeType:void 0,i=e?e.qualityArgument:void 0,n=e?e.idealAspect:void 0,{width:r,height:a,idealAspect:o,aspect:l}=this[sd],{dpr:c,scaleFactor:h}=this[hd];let d=r*h*c,A=a*h*c,p=0,m=0;if(!0===n)if(o>l){const e=A;A=Math.round(d/o),m=(e-A)/2}else{const e=d;d=Math.round(A*o),p=(e-d)/2}Pu.width=d,Pu.height=A;try{return new Promise((async(e,n)=>{Pu.getContext("2d").drawImage(this[hd].displayCanvas(this[sd]),p,m,d,A,0,0,d,A),Pu.toBlob((t=>{if(!t)return n(new Error("Unable to retrieve canvas blob"));e(t)}),t,i)}))}finally{this[Wu]({width:r,height:a})}}registerEffectComposer(e){e.setRenderer(this[hd].threeRenderer),e.setMainCamera(this[sd].getCamera()),e.setMainScene(this[sd]),this[sd].effectRenderer=e}unregisterEffectComposer(){this[sd].effectRenderer=null}registerRenderer(e){this[sd].externalRenderer=e}unregisterRenderer(){this[sd].externalRenderer=null}get[Yu](){return this[Ku]}get[Ku](){return null==this.alt||"null"===this.alt?this[Nu]:this.alt}[dd](){return this[Gu]}[Ad](){return this.loaded&&this[Xu]}[pd](){return!!this.src&&this[Xu]}[Wu]({width:e,height:t}){0!==e&&0!==t&&(this[id].style.width=`${e}px`,this[id].style.height=`${t}px`,this[cd]({width:e,height:t}))}[od](e,t){var i;null===(i=this[sd].effectRenderer)||void 0===i||i.beforeRender(e,t)}[td](){this[Gu]||(this[Gu]=!0,this[Zu]=performance.now())}[ad](){this[sd].queueRender()}[ld](){}[Ju](e){this[Vu]=e;const t=this.getRootNode();null!=t&&t.activeElement===this&&this[$u].textContent!=e&&(this[$u].textContent=e)}[(Lu=Hu,Du=zu,cd)](e){this[sd].setSize(e.width,e.height)}async[(Uu=ku,ed)](){const e=this[sd];if(this.loaded||!this[pd]()||this.src===e.url)return;this.generateSchema&&e.updateSchema(this.src),this[Ju]("Loading"),e.stopAnimation();const t=this[ud].beginActivity(),i=this.src;try{const n=e.setSource(i,(e=>t(.95*clamp(e,0,1)))),r=this[Ns]();await Promise.all([n,r]),this[td](),this[ld](),this.updateComplete.then((()=>{this.dispatchEvent(new CustomEvent("before-render"))})),await new Promise((e=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.dispatchEvent(new CustomEvent("load",{detail:{url:i}})),e()}))}))}))}catch(e){this.dispatchEvent(new CustomEvent("error",{detail:{type:"loadfailure",sourceError:e}}))}finally{t(1)}}}__decorate$4([n$8({type:String})],ModelViewerElementBase.prototype,"alt",void 0),__decorate$4([n$8({type:String})],ModelViewerElementBase.prototype,"src",void 0),__decorate$4([n$8({type:Boolean,attribute:"with-credentials"})],ModelViewerElementBase.prototype,"withCredentials",void 0),__decorate$4([n$8({type:Boolean,attribute:"generate-schema"})],ModelViewerElementBase.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 __decorate$3=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};const md=Symbol("changeAnimation"),gd=Symbol("paused"),fd={repetitions:1/0,pingpong:!1},vd=Symbol("hotspotMap"),Ed=Symbol("mutationCallback"),yd=Symbol("observer"),_d=Symbol("addHotspot"),xd=Symbol("removeHotspot"),Sd=new Matrix4;
/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.6.9
*/
var durl=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(durl(""))}catch(us){durl=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var Cd=Uint8Array,Md=Uint16Array,bd=Uint32Array,Id=new Cd([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]),wd=new Cd([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]),Td=new Cd([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),freb=function(e,t){for(var i=new Md(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new bd(i[30]);for(n=1;n<30;++n)for(var a=i[n];a<i[n+1];++a)r[a]=a-i[n]<<5|n;return[i,r]},Bd=freb(Id,2),Rd=Bd[0],Ld=Bd[1];Rd[28]=258,Ld[258]=28;for(var Dd=freb(wd,0)[1],Ud=new Md(32768),Pd=0;Pd<32768;++Pd){var Fd=(43690&Pd)>>>1|(21845&Pd)<<1;Fd=(61680&(Fd=(52428&Fd)>>>2|(13107&Fd)<<2))>>>4|(3855&Fd)<<4,Ud[Pd]=((65280&Fd)>>>8|(255&Fd)<<8)>>>1}var hMap=function(e,t,i){for(var n=e.length,r=0,a=new Md(t);r<n;++r)++a[e[r]-1];var o,l=new Md(t);for(r=0;r<t;++r)l[r]=l[r-1]+a[r-1]<<1;if(i){o=new Md(1<<t);var c=15-t;for(r=0;r<n;++r)if(e[r])for(var h=r<<4|e[r],d=t-e[r],A=l[e[r]-1]++<<d,p=A|(1<<d)-1;A<=p;++A)o[Ud[A]>>>c]=h}else for(o=new Md(n),r=0;r<n;++r)e[r]&&(o[r]=Ud[l[e[r]-1]++]>>>15-e[r]);return o},Nd=new Cd(288);for(Pd=0;Pd<144;++Pd)Nd[Pd]=8;for(Pd=144;Pd<256;++Pd)Nd[Pd]=9;for(Pd=256;Pd<280;++Pd)Nd[Pd]=7;for(Pd=280;Pd<288;++Pd)Nd[Pd]=8;var Qd=new Cd(32);for(Pd=0;Pd<32;++Pd)Qd[Pd]=5;var Od=hMap(Nd,9,0),kd=hMap(Qd,5,0),shft=function(e){return(e/8|0)+(7&e&&1)},slc=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof Md?Md:e instanceof bd?bd:Cd)(i-t);return n.set(e.subarray(t,i)),n},wbits=function(e,t,i){i<<=7&t;var n=t/8|0;e[n]|=i,e[n+1]|=i>>>8},wbits16=function(e,t,i){i<<=7&t;var n=t/8|0;e[n]|=i,e[n+1]|=i>>>8,e[n+2]|=i>>>16},hTree=function(e,t){for(var i=[],n=0;n<e.length;++n)e[n]&&i.push({s:n,f:e[n]});var r=i.length,a=i.slice();if(!r)return[Vd,0];if(1==r){var o=new Cd(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var l=i[0],c=i[1],h=0,d=1,A=2;for(i[0]={s:-1,f:l.f+c.f,l,r:c};d!=r-1;)l=i[i[h].f<i[A].f?h++:A++],c=i[h!=d&&i[h].f<i[A].f?h++:A++],i[d++]={s:-1,f:l.f+c.f,l,r:c};var p=a[0].s;for(n=1;n<r;++n)a[n].s>p&&(p=a[n].s);var m=new Md(p+1),g=ln(i[d-1],m,0);if(g>t){n=0;var f=0,v=g-t,E=1<<v;for(a.sort((function(e,t){return m[t.s]-m[e.s]||e.f-t.f}));n<r;++n){var y=a[n].s;if(!(m[y]>t))break;f+=E-(1<<g-m[y]),m[y]=t}for(f>>>=v;f>0;){var _=a[n].s;m[_]<t?f-=1<<t-m[_]++-1:++n}for(;n>=0&&f;--n){var x=a[n].s;m[x]==t&&(--m[x],++f)}g=t}return[new Cd(m),g]},ln=function(e,t,i){return-1==e.s?Math.max(ln(e.l,t,i+1),ln(e.r,t,i+1)):t[e.s]=i},lc=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Md(++t),n=0,r=e[0],a=1,w=function(e){i[n++]=e},o=1;o<=t;++o)if(e[o]==r&&o!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)w(32754);a>2&&(w(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(w(r),--a;a>6;a-=6)w(8304);a>2&&(w(a-3<<5|8208),a=0)}for(;a--;)w(r);a=1,r=e[o]}return[i.subarray(0,n),t]},clen=function(e,t){for(var i=0,n=0;n<t.length;++n)i+=e[n]*t[n];return i},wfblk=function(e,t,i){var n=i.length,r=shft(t+2);e[r]=255&n,e[r+1]=n>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var a=0;a<n;++a)e[r+a+4]=i[a];return 8*(r+4+n)},wblk=function(e,t,i,n,r,a,o,l,c,h,d){wbits(t,d++,i),++r[256];for(var A=hTree(r,15),p=A[0],m=A[1],g=hTree(a,15),f=g[0],v=g[1],E=lc(p),y=E[0],_=E[1],x=lc(f),S=x[0],C=x[1],b=new Md(19),I=0;I<y.length;++I)b[31&y[I]]++;for(I=0;I<S.length;++I)b[31&S[I]]++;for(var T=hTree(b,7),B=T[0],U=T[1],F=19;F>4&&!B[Td[F-1]];--F);var O,G,W,q,X=h+5<<3,j=clen(r,Nd)+clen(a,Qd)+o,Y=clen(r,p)+clen(a,f)+o+14+3*F+clen(b,B)+(2*b[16]+3*b[17]+7*b[18]);if(X<=j&&X<=Y)return wfblk(t,d,e.subarray(c,c+h));if(wbits(t,d,1+(Y<j)),d+=2,Y<j){O=hMap(p,m,0),G=p,W=hMap(f,v,0),q=f;var K=hMap(B,U,0);wbits(t,d,_-257),wbits(t,d+5,C-1),wbits(t,d+10,F-4),d+=14;for(I=0;I<F;++I)wbits(t,d+3*I,B[Td[I]]);d+=3*F;for(var $=[y,S],J=0;J<2;++J){var ee=$[J];for(I=0;I<ee.length;++I){var te=31&ee[I];wbits(t,d,K[te]),d+=B[te],te>15&&(wbits(t,d,ee[I]>>>5&127),d+=ee[I]>>>12)}}}else O=Od,G=Nd,W=kd,q=Qd;for(I=0;I<l;++I)if(n[I]>255){te=n[I]>>>18&31;wbits16(t,d,O[te+257]),d+=G[te+257],te>7&&(wbits(t,d,n[I]>>>23&31),d+=Id[te]);var ie=31&n[I];wbits16(t,d,W[ie]),d+=q[ie],ie>3&&(wbits16(t,d,n[I]>>>5&8191),d+=wd[ie])}else wbits16(t,d,O[n[I]]),d+=G[n[I]];return wbits16(t,d,O[256]),d+G[256]},Gd=new bd([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vd=new Cd(0),Hd=function(){for(var e=new bd(256),t=0;t<256;++t){for(var i=t,n=9;--n;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),crc=function(){var e=-1;return{p:function(t){for(var i=e,n=0;n<t.length;++n)i=Hd[255&i^t[n]]^i>>>8;e=i},d:function(){return~e}}},dopt=function(e,t,i,n,r){return function(e,t,i,n,r,a){var o=e.length,l=new Cd(n+o+5*(1+Math.ceil(o/7e3))+r),c=l.subarray(n,l.length-r),h=0;if(!t||o<8)for(var d=0;d<=o;d+=65535){var A=d+65535;A<o?h=wfblk(c,h,e.subarray(d,A)):(c[d]=a,h=wfblk(c,h,e.subarray(d,o)))}else{for(var p=Gd[t-1],m=p>>>13,g=8191&p,f=(1<<i)-1,v=new Md(32768),E=new Md(f+1),y=Math.ceil(i/3),_=2*y,hsh=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<_)&f},x=new bd(25e3),S=new Md(288),C=new Md(32),b=0,I=0,T=(d=0,0),B=0,U=0;d<o;++d){var F=hsh(d),O=32767&d,G=E[F];if(v[O]=G,E[F]=O,B<=d){var W=o-d;if((b>7e3||T>24576)&&W>423){h=wblk(e,c,0,x,S,C,I,T,U,d-U,h),T=b=I=0,U=d;for(var q=0;q<286;++q)S[q]=0;for(q=0;q<30;++q)C[q]=0}var X=2,j=0,Y=g,K=O-G&32767;if(W>2&&F==hsh(d-K))for(var $=Math.min(m,W)-1,J=Math.min(32767,d),ee=Math.min(258,W);K<=J&&--Y&&O!=G;){if(e[d+X]==e[d+X-K]){for(var te=0;te<ee&&e[d+te]==e[d+te-K];++te);if(te>X){if(X=te,j=K,te>$)break;var ie=Math.min(K,te-2),ne=0;for(q=0;q<ie;++q){var re=d-K+q+32768&32767,se=re-v[re]+32768&32767;se>ne&&(ne=se,G=re)}}}K+=(O=G)-(G=v[O])+32768&32767}if(j){x[T++]=268435456|Ld[X]<<18|Dd[j];var ae=31&Ld[X],oe=31&Dd[j];I+=Id[ae]+wd[oe],++S[257+ae],++C[oe],B=d+X,++b}else x[T++]=e[d],++S[e[d]]}}h=wblk(e,c,a,x,S,C,I,T,U,d-U,h),!a&&7&h&&(h=wfblk(c,h+1,Vd))}return slc(l,0,n+shft(h)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,n,!r)},mrg=function(e,t){var i={};for(var n in e)i[n]=e[n];for(var n in t)i[n]=t[n];return i},wbytes=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function deflateSync(e,t){return dopt(e,t||{},0,0)}var fltn=function(e,t,i,n){for(var r in e){var a=e[r],o=t+r;a instanceof Cd?i[o]=[a,n]:Array.isArray(a)?i[o]=[a[0],mrg(n,a[1])]:fltn(a,o+"/",i,n)}},zd="undefined"!=typeof TextEncoder&&new TextEncoder,Wd="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wd.decode(Vd,{stream:!0}),1}catch(us){}function strToU8(e,t){if(t){for(var i=new Cd(e.length),n=0;n<e.length;++n)i[n]=e.charCodeAt(n);return i}if(zd)return zd.encode(e);var r=e.length,a=new Cd(e.length+(e.length>>1)),o=0,w=function(e){a[o++]=e};for(n=0;n<r;++n){if(o+5>a.length){var l=new Cd(o+8+(r-n<<1));l.set(a),a=l}var c=e.charCodeAt(n);c<128||t?w(c):c<2048?(w(192|c>>6),w(128|63&c)):c>55295&&c<57344?(w(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++n))>>18),w(128|c>>12&63),w(128|c>>6&63),w(128|63&c)):(w(224|c>>12),w(128|c>>6&63),w(128|63&c))}return slc(a,0,o)}var exfl=function(e){var t=0;if(e)for(var i in e){var n=e[i].length;if(n>65535)throw"extra field too long";t+=n+4}return t},wzh=function(e,t,i,n,r,a,o,l){var c=n.length,h=i.extra,d=l&&l.length,A=exfl(h);wbytes(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=i.os),e[t]=20,t+=2,e[t++]=i.flag<<1|(null==a&&8),e[t++]=r&&8,e[t++]=255&i.compression,e[t++]=i.compression>>8;var p=new Date(null==i.mtime?Date.now():i.mtime),m=p.getFullYear()-1980;if(m<0||m>119)throw"date not in range 1980-2099";if(wbytes(e,t,m<<25|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),t+=4,null!=a&&(wbytes(e,t,i.crc),wbytes(e,t+4,a),wbytes(e,t+8,i.size)),wbytes(e,t+12,c),wbytes(e,t+14,A),t+=16,null!=o&&(wbytes(e,t,d),wbytes(e,t+6,i.attrs),wbytes(e,t+10,o),t+=14),e.set(n,t),t+=c,A)for(var g in h){var f=h[g],v=f.length;wbytes(e,t,+g),wbytes(e,t+2,v),e.set(f,t+4),t+=4+v}return d&&(e.set(l,t),t+=d),t};function zipSync(e,t){t||(t={});var i={},n=[];fltn(e,"",i,t);var r=0,a=0;for(var o in i){var l=i[o],c=l[0],h=l[1],d=0==h.level?0:8,A=(b=strToU8(o)).length,p=h.comment,m=p&&strToU8(p),g=m&&m.length,f=exfl(h.extra);if(A>65535)throw"filename too long";var v=d?deflateSync(c,h):c,E=v.length,y=crc();y.p(c),n.push(mrg(h,{size:c.length,crc:y.d(),c:v,f:b,m,u:A!=o.length||m&&p.length!=g,o:r,compression:d})),r+=30+A+f+E,a+=76+2*(A+f)+(g||0)+E}for(var _=new Cd(a+22),x=r,S=a-r,C=0;C<n.length;++C){var b=n[C];wzh(_,b.o,b,b.f,b.u,b.c.length);var I=30+b.f.length+exfl(b.extra);_.set(b.c,b.o+I),wzh(_,r,b,b.f,b.u,b.c.length,b.o,b.m),r+=16+I+(b.m?b.m.length:0)}return function(e,t,i,n,r){wbytes(e,t,101010256),wbytes(e,t+8,i),wbytes(e,t+10,i),wbytes(e,t+12,n),wbytes(e,t+16,r)}(_,r,n.length,S,x),_}class USDZExporter{async parse(e,t={}){t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1},t);const i={},n="model.usda";i[n]=null;let r=buildHeader();r+=function buildSceneStart(e){return`def Xform "Root"\n{\n\tdef Scope "Scenes" (\n\t\tkind = "sceneLibrary"\n\t)\n\t{\n\t\tdef Xform "Scene" (\n\t\t\tcustomData = {\n\t\t\t\tbool preliminary_collidesWithEnvironment = 0\n\t\t\t\tstring sceneName = "Scene"\n\t\t\t}\n\t\t\tsceneName = "Scene"\n\t\t)\n\t\t{\n\t\ttoken preliminary:anchoring:type = "${e.ar.anchoring.type}"\n\t\ttoken preliminary:planeAnchoring:alignment = "${e.ar.planeAnchoring.alignment}"\n\n`}(t);const a={},o={};e.traverseVisible((e=>{if(e.isMesh){const t=e.geometry,n=e.material;if(n.isMeshStandardMaterial){const o="geometries/Geometry_"+t.id+".usda";if(!(o in i)){const e=function buildMeshObject(e){const t=function buildMesh(e){const t="Geometry",i=e.attributes,n=i.position.count;return`\n\tdef Mesh "${t}"\n\t{\n\t\tint[] faceVertexCounts = [${function buildMeshVertexCount(e){const t=null!==e.index?e.index.count:e.attributes.position.count;return Array(t/3).fill(3).join(", ")}(e)}]\n\t\tint[] faceVertexIndices = [${function buildMeshVertexIndices(e){const t=e.index,i=[];if(null!==t)for(let e=0;e<t.count;e++)i.push(t.getX(e));else{const t=e.attributes.position.count;for(let e=0;e<t;e++)i.push(e)}return i.join(", ")}(e)}]\n\t\tnormal3f[] normals = [${buildVector3Array(i.normal,n)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)\n\t\tpoint3f[] points = [${buildVector3Array(i.position,n)}]\n${function buildPrimvars(e,t){let i="";for(let n=0;n<4;n++){const r=n>0?n:"",a=e["uv"+r];void 0!==a&&(i+=`\n\t\ttexCoord2f[] primvars:st${r} = [${buildVector2Array(a,t)}] (\n\t\t\tinterpolation = "vertex"\n\t\t)`)}return i}(i,n)}\n\t\tuniform token subdivisionScheme = "none"\n\t}\n`}(e);return`\ndef "Geometry"\n{\n${t}\n}\n`}(t);i[o]=function buildUSDFileAsString(e){let t=buildHeader();return t+=e,strToU8(t)}(e)}n.uuid in a||(a[n.uuid]=n),r+=function buildXform(e,t,i){const n="Object_"+e.id,r=buildMatrix(e.matrixWorld);e.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",e);return`def Xform "${n}" (\n\tprepend references = @./geometries/Geometry_${t.id}.usda@</Geometry>\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ${r}\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\trel material:binding = </Materials/Material_${i.id}>\n}\n\n`}(e,t,n)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",e)}else e.isCamera&&(r+=function buildCamera(e){const t=e.name?e.name:"Camera_"+e.id,i=buildMatrix(e.matrixWorld);e.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",e);return e.isOrthographicCamera?`def Camera "${t}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${i}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${e.near.toPrecision(qd)}, ${e.far.toPrecision(qd)})\n\t\t\tfloat horizontalAperture = ${(10*(Math.abs(e.left)+Math.abs(e.right))).toPrecision(qd)}\n\t\t\tfloat verticalAperture = ${(10*(Math.abs(e.top)+Math.abs(e.bottom))).toPrecision(qd)}\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t`:`def Camera "${t}"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ${i}\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (${e.near.toPrecision(qd)}, ${e.far.toPrecision(qd)})\n\t\t\tfloat focalLength = ${e.getFocalLength().toPrecision(qd)}\n\t\t\tfloat focusDistance = ${e.focus.toPrecision(qd)}\n\t\t\tfloat horizontalAperture = ${e.getFilmWidth().toPrecision(qd)}\n\t\t\ttoken projection = "perspective"\n\t\t\tfloat verticalAperture = ${e.getFilmHeight().toPrecision(qd)}\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.
 */(e))})),r+="\n\t\t}\n\t}\n}\n\n",r+=function buildMaterials(e,t,i=!1){const n=[];for(const r in e){const a=e[r];n.push(buildMaterial(a,t,i))}return`def "Materials"\n{\n${n.join("")}\n}\n\n`}(a,o,t.quickLookCompatible),i[n]=strToU8(r),r=null;for(const e in o){const t=o[e],n=imageToCanvas(t.image,t.flipY),r=await new Promise((e=>n.toBlob(e,"image/png",1)));i[`textures/Texture_${e}.png`]=new Uint8Array(await r.arrayBuffer())}let l=0;for(const e in i){const t=i[e];l+=34+e.length;const n=63&l;if(4!==n){const r=new Uint8Array(64-n);i[e]=[t,{extra:{12345:r}}]}l=t.length}return zipSync(i,{level:0})}}function imageToCanvas(e,t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=1024/Math.max(e.width,e.height),n=document.createElement("canvas");n.width=e.width*Math.min(1,i),n.height=e.height*Math.min(1,i);const r=n.getContext("2d");return!0===t&&(r.translate(0,n.height),r.scale(1,-1)),r.drawImage(e,0,0,n.width,n.height),n}throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const qd=7;function buildHeader(){return'#usda 1.0\n(\n\tcustomLayerData = {\n\t\tstring creator = "Three.js USDZExporter"\n\t}\n\tmetersPerUnit = 1\n\tupAxis = "Y"\n)\n\n'}function buildMatrix(e){const t=e.elements;return`( ${buildMatrixRow(t,0)}, ${buildMatrixRow(t,4)}, ${buildMatrixRow(t,8)}, ${buildMatrixRow(t,12)} )`}function buildMatrixRow(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function buildVector3Array(e,t){if(void 0===e)return console.warn("USDZExporter: Normals missing."),Array(t).fill("(0, 0, 0)").join(", ");const i=[];for(let t=0;t<e.count;t++){const n=e.getX(t),r=e.getY(t),a=e.getZ(t);i.push(`(${n.toPrecision(qd)}, ${r.toPrecision(qd)}, ${a.toPrecision(qd)})`)}return i.join(", ")}function buildVector2Array(e,t){if(void 0===e)return console.warn("USDZExporter: UVs missing."),Array(t).fill("(0, 0)").join(", ");const i=[];for(let t=0;t<e.count;t++){const n=e.getX(t),r=e.getY(t);i.push(`(${n.toPrecision(qd)}, ${1-r.toPrecision(qd)})`)}return i.join(", ")}function buildMaterial(e,t,i=!1){const n="\t\t\t",r=[],a=[];function buildTexture(n,r,a){const o=n.source.id+"_"+n.flipY;t[o]=n;const l=n.channel>0?"st"+n.channel:"st",c={1e3:"repeat",1001:"clamp",1002:"mirror"},h=n.repeat.clone(),d=n.offset.clone(),A=n.rotation,p=Math.sin(A),m=Math.cos(A);return d.y=1-d.y-h.y,i?(d.x=d.x/h.x,d.y=d.y/h.y,d.x+=p/h.x,d.y+=m-1):(d.x+=p*h.x,d.y+=(1-m)*h.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 = "${l}"\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 = </Materials/Material_${e.id}/PrimvarReader_${r}.outputs:result>\n\t\t\tfloat inputs:rotation = ${(A*(180/Math.PI)).toFixed(qd)}\n\t\t\tfloat2 inputs:scale = ${buildVector2(h)}\n\t\t\tfloat2 inputs:translation = ${buildVector2(d)}\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_${o}.png@\n\t\t\tfloat2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${r}.outputs:result>\n\t\t\t${void 0!==a?"float4 inputs:scale = "+function buildColor4(e){return`(${e.r}, ${e.g}, ${e.b}, 1.0)`}(a):""}\n\t\t\ttoken inputs:sourceColorSpace = "${n.colorSpace===Me?"raw":"sRGB"}"\n\t\t\ttoken inputs:wrapS = "${c[n.wrapS]}"\n\t\t\ttoken inputs:wrapT = "${c[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${e.transparent||e.alphaTest>0?"float outputs:a":""}\n\t\t}`}return 2===e.side&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",e),null!==e.map?(r.push(`${n}color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`),e.transparent?r.push(`${n}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`):e.alphaTest>0&&(r.push(`${n}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`),r.push(`${n}float inputs:opacityThreshold = ${e.alphaTest}`)),a.push(buildTexture(e.map,"diffuse",e.color))):r.push(`${n}color3f inputs:diffuseColor = ${buildColor(e.color)}`),null!==e.emissiveMap?(r.push(`${n}color3f inputs:emissiveColor.connect = </Materials/Material_${e.id}/Texture_${e.emissiveMap.id}_emissive.outputs:rgb>`),a.push(buildTexture(e.emissiveMap,"emissive"))):e.emissive.getHex()>0&&r.push(`${n}color3f inputs:emissiveColor = ${buildColor(e.emissive)}`),null!==e.normalMap&&(r.push(`${n}normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`),a.push(buildTexture(e.normalMap,"normal"))),null!==e.aoMap&&(r.push(`${n}float inputs:occlusion.connect = </Materials/Material_${e.id}/Texture_${e.aoMap.id}_occlusion.outputs:r>`),a.push(buildTexture(e.aoMap,"occlusion"))),null!==e.roughnessMap&&1===e.roughness?(r.push(`${n}float inputs:roughness.connect = </Materials/Material_${e.id}/Texture_${e.roughnessMap.id}_roughness.outputs:g>`),a.push(buildTexture(e.roughnessMap,"roughness"))):r.push(`${n}float inputs:roughness = ${e.roughness}`),null!==e.metalnessMap&&1===e.metalness?(r.push(`${n}float inputs:metallic.connect = </Materials/Material_${e.id}/Texture_${e.metalnessMap.id}_metallic.outputs:b>`),a.push(buildTexture(e.metalnessMap,"metallic"))):r.push(`${n}float inputs:metallic = ${e.metalness}`),null!==e.alphaMap?(r.push(`${n}float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`),r.push(`${n}float inputs:opacityThreshold = 0.0001`),a.push(buildTexture(e.alphaMap,"opacity"))):r.push(`${n}float inputs:opacity = ${e.opacity}`),e.isMeshPhysicalMaterial&&(r.push(`${n}float inputs:clearcoat = ${e.clearcoat}`),r.push(`${n}float inputs:clearcoatRoughness = ${e.clearcoatRoughness}`),r.push(`${n}float inputs:ior = ${e.ior}`)),`\n\tdef Material "Material_${e.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 = </Materials/Material_${e.id}/PreviewSurface.outputs:surface>\n\n${a.join("\n")}\n\n\t}\n`}function buildColor(e){return`(${e.r}, ${e.g}, ${e.b})`}function buildVector2(e){return`(${e.x}, ${e.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 __decorate$2=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};let Xd=!1,jd=!1;const Yd="#model-viewer-no-ar-fallback",Kd=($d=["quick-look","scene-viewer","webxr","none"],e=>{try{const t=Po(e),i=(t.length?t[0].terms:[]).filter((e=>e&&"ident"===e.type)).map((e=>e.value)).filter((e=>$d.indexOf(e)>-1)),n=new Set;for(const e of i)n.add(e);return n}catch(e){}return new Set});var $d;const Jd="quick-look",Zd="scene-viewer",eA="webxr",tA="none",iA=Symbol("arButtonContainer"),nA=Symbol("enterARWithWebXR"),rA=Symbol("openSceneViewer"),sA=Symbol("openIOSARQuickLook"),aA=Symbol("canActivateAR"),oA=Symbol("arMode"),lA=Symbol("arModes"),cA=Symbol("arAnchor"),hA=Symbol("preload"),uA=Symbol("onARButtonContainerClick"),dA=Symbol("onARStatus"),AA=Symbol("onARTracking"),pA=Symbol("onARTap"),mA=Symbol("selectARMode"),gA=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 __decorate$1=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};const fA="auto",vA="auto",EA="eager",yA=Symbol("defaultProgressBarElement"),_A=Symbol("posterContainerElement"),xA=Symbol("defaultPosterElement"),SA=Symbol("shouldDismissPoster"),CA=Symbol("hidePoster"),MA=Symbol("modelIsRevealed"),bA=Symbol("updateProgressBar"),IA=Symbol("ariaLabelCallToAction"),wA=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 __decorate=function(e,t,i,n){for(var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n,l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o};const TA=Math.PI/32,BA={basis:[degreesToRadians(numberNode(TA,"rad"))],keywords:{auto:[null]}},RA=Symbol("autoRotateStartTime"),LA=Symbol("radiansPerSecond"),DA=Symbol("syncRotationRate"),UA=Symbol("onCameraChange"),PA=(e=>{var t,i,n;class AnnotationModelViewerElement extends e{constructor(){super(...arguments),this[t]=new Map,this[i]=e=>{e.forEach((e=>{e instanceof MutationRecord&&"childList"!==e.type||(e.addedNodes.forEach((e=>{this[_d](e)})),e.removedNodes.forEach((e=>{this[xd](e)})),this[ad]())}))},this[n]=new MutationObserver(this[Ed])}connectedCallback(){super.connectedCallback();for(let e=0;e<this.children.length;++e)this[_d](this.children[e]);const{ShadyDOM:e}=self;null==e?this[yd].observe(this,{childList:!0}):this[yd]=e.observeChildren(this,this[Ed])}disconnectedCallback(){super.disconnectedCallback();const{ShadyDOM:e}=self;null==e?this[yd].disconnect():e.unobserveChildren(this[yd])}[(t=vd,i=Ed,n=yd,od)](e,t){super[od](e,t);const i=this[sd],{annotationRenderer:n}=i,r=i.getCamera();i.shouldRender()&&(i.updateSurfaceHotspots(),i.updateHotspotsVisibility(r.position),n.domElement.style.display="",n.render(i,r))}updateHotspot(e){const t=this[vd].get(e.name);null!=t&&(t.updatePosition(e.position),t.updateNormal(e.normal),t.surface=e.surface,this[ad]())}queryHotspot(e){const t=this[vd].get(e);if(null==t)return null;const i=toVector3D(t.position),n=toVector3D(t.normal),r=t.facingCamera,a=this[sd],o=a.getCamera(),l=new Vector3;l.setFromMatrixPosition(t.matrixWorld),l.project(o);const c=a.width/2,h=a.height/2;l.x=l.x*c+c,l.y=-l.y*h+h;const d=toVector3D(new Vector3(l.x,l.y,l.z));return Number.isFinite(d.x)&&Number.isFinite(d.y)?{position:i,normal:n,canvasPosition:d,facingCamera:r}:null}positionAndNormalFromPoint(e,t){const i=this[sd],n=i.getNDC(e,t),r=i.positionAndNormalFromPoint(n);if(null==r)return null;Sd.copy(i.target.matrixWorld).invert();const a=toVector3D(r.position.applyMatrix4(Sd)),o=toVector3D(r.normal.transformDirection(Sd));let l=null;return null!=r.uv&&(l=toVector2D(r.uv)),{position:a,normal:o,uv:l}}surfaceFromPoint(e,t){const i=this[sd],n=i.getNDC(e,t);return i.surfaceFromPoint(n)}[_d](e){if(!(e instanceof HTMLElement&&0===e.slot.indexOf("hotspot")))return;let t=this[vd].get(e.slot);null!=t?t.increment():(t=new Hotspot({name:e.slot,position:e.dataset.position,normal:e.dataset.normal,surface:e.dataset.surface}),this[vd].set(e.slot,t),this[sd].addHotspot(t)),this[sd].queueRender()}[xd](e){if(!(e instanceof HTMLElement))return;const t=this[vd].get(e.slot);t&&(t.decrement()&&(this[sd].removeHotspot(t),this[vd].delete(e.slot)),this[sd].queueRender())}}return AnnotationModelViewerElement})((e=>{var t,i,n;class SceneGraphModelViewerElement extends e{constructor(){super(...arguments),this[t]=void 0,this[i]=null,this[n]=null,this.variantName=null,this.orientation="0 0 0",this.scale="1 1 1"}get model(){return this[su]}get availableVariants(){return this.model?this.model[eu]():[]}get originalGltfJson(){return this[ru]}[(t=su,i=nu,n=ru,au)](){return()=>{this[ad]()}}[ou](e){return e.encoding=Ce,e.wrapS=b,e.wrapT=b,new Texture(this[au](),e)}async createTexture(e,t="image/png"){const{textureUtils:i}=this[hd],n=await i.loadImage(e);return n.userData.mimeType=t,this[ou](n)}async createLottieTexture(e,t=1){const{textureUtils:i}=this[hd],n=await i.loadLottie(e,t);return this[ou](n)}createVideoTexture(e){const t=document.createElement("video");t.src=e,t.muted=!0,t.playsInline=!0,t.loop=!0,t.play();const i=new VideoTexture(t);return this[ou](i)}createCanvasTexture(){const e=document.createElement("canvas"),t=new CanvasTexture(e);return this[ou](t)}async updated(e){if(super.updated(e),e.has("variantName")){const e=this[ud].beginActivity();e(.1);const t=this[su],{variantName:i}=this;null!=t&&(await t[Yh](i),this[ad](),this.dispatchEvent(new CustomEvent("variant-applied"))),e(1)}if(e.has("orientation")||e.has("scale")){if(!this.loaded)return;const e=this[sd];e.applyTransform(),e.updateBoundingBox(),e.updateShadow(),this[hd].arRenderer.onUpdateScene(),this[ad]()}}[ld](){super[ld]();const{currentGLTF:e}=this[sd];if(null!=e){const{correlatedSceneGraph:t}=e;null!=t&&e!==this[nu]&&(this[su]=new Model(t,this[au]()),this[ru]=JSON.parse(JSON.stringify(t.gltf))),"variants"in e.userData&&this.requestUpdate("variantName")}this[nu]=e}async exportScene(e){const t=this[sd];return new Promise((async(i,n)=>{const r={binary:!0,onlyVisible:!0,maxTextureSize:1/0,includeCustomExtensions:!1,forceIndices:!1};Object.assign(r,e),r.animations=t.animations,r.truncateDrawRange=!0;const a=t.shadow;let o=!1;null!=a&&(o=a.visible,a.visible=!1),await this[su][jh]();(new GLTFExporter).register((e=>new GLTFExporterMaterialsVariantsExtension(e))).parse(t.model,(e=>i(new Blob([r.binary?e:JSON.stringify(e)],{type:r.binary?"application/octet-stream":"application/json"}))),(()=>n("glTF export failed")),r),null!=a&&(a.visible=o)}))}materialFromPoint(e,t){const i=this[su];if(null==i)return null;const n=this[sd],r=n.getNDC(e,t),a=n.hitFromPoint(r);return null==a||null==a.face?null:i[Kh](a)}}return __decorate$5([n$8({type:String,attribute:"variant-name"})],SceneGraphModelViewerElement.prototype,"variantName",void 0),__decorate$5([n$8({type:String,attribute:"orientation"})],SceneGraphModelViewerElement.prototype,"orientation",void 0),__decorate$5([n$8({type:String,attribute:"scale"})],SceneGraphModelViewerElement.prototype,"scale",void 0),SceneGraphModelViewerElement})((e=>{var t,i,n;class StagingModelViewerElement extends e{constructor(){super(...arguments),this.autoRotate=!1,this.autoRotateDelay=3e3,this.rotationPerSecond="auto",this[t]=performance.now(),this[i]=0,this[n]=e=>{this.autoRotate&&"user-interaction"===e.detail.source&&(this[RA]=performance.now())}}connectedCallback(){super.connectedCallback(),this.addEventListener("camera-change",this[UA]),this[RA]=performance.now()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("camera-change",this[UA]),this[RA]=performance.now()}updated(e){super.updated(e),e.has("autoRotate")&&(this[RA]=performance.now())}[(t=RA,i=LA,DA)](e){this[LA]=e[0]}[od](e,t){if(super[od](e,t),!this.autoRotate||!this[Ad]()||this[hd].isPresenting)return;const i=Math.min(t,e-this[RA]-this.autoRotateDelay);i>0&&(this[sd].yaw=this.turntableRotation+this[LA]*i*.001)}get turntableRotation(){return this[sd].yaw}resetTurntableRotation(e=0){this[sd].yaw=e}}return n=UA,__decorate([n$8({type:Boolean,attribute:"auto-rotate"})],StagingModelViewerElement.prototype,"autoRotate",void 0),__decorate([n$8({type:Number,attribute:"auto-rotate-delay"})],StagingModelViewerElement.prototype,"autoRotateDelay",void 0),__decorate([style({intrinsics:BA,updateHandler:DA}),n$8({type:String,attribute:"rotation-per-second"})],StagingModelViewerElement.prototype,"rotationPerSecond",void 0),StagingModelViewerElement})((e=>{var t,i,n;class EnvironmentModelViewerElement extends e{constructor(){super(...arguments),this.environmentImage=null,this.skyboxImage=null,this.shadowIntensity=0,this.shadowSoftness=1,this.exposure=1,this[t]=null,this[i]=null,this[n]=null}updated(e){super.updated(e),e.has("shadowIntensity")&&(this[sd].setShadowIntensity(.5*this.shadowIntensity),this[ad]()),e.has("shadowSoftness")&&(this[sd].setShadowSoftness(this.shadowSoftness),this[ad]()),e.has("exposure")&&(this[sd].exposure=this.exposure,this[ad]()),(e.has("environmentImage")||e.has("skyboxImage"))&&this[pd]()&&this[Ns]()}hasBakedShadow(){return this[sd].bakedShadows.size>0}async[(t=Ps,i=Fs,n=Qs,Ns)](){const{skyboxImage:e,environmentImage:t}=this;null!=this[Qs]&&(this[Qs](),this[Qs]=null);const{textureUtils:i}=this[hd];if(null==i)return;const n=this[ud].beginActivity();try{const{environmentMap:r,skybox:a}=await i.generateEnvironmentMapAndSkybox(deserializeUrl(e),t,(e=>n(clamp(e,0,1))));this[Ps]!==r&&(this[Ps]=r,this.dispatchEvent(new CustomEvent("environment-change"))),this[Fs]=null!=a?a.name===r.name?r:a:null,this[sd].setEnvironmentAndSkybox(this[Ps],this[Fs]),this[sd].dispatchEvent({type:"envmap-update"})}catch(e){if(e instanceof Error)throw this[sd].setEnvironmentAndSkybox(null,null),e}finally{n(1)}}}return __decorate$7([n$8({type:String,attribute:"environment-image"})],EnvironmentModelViewerElement.prototype,"environmentImage",void 0),__decorate$7([n$8({type:String,attribute:"skybox-image"})],EnvironmentModelViewerElement.prototype,"skyboxImage",void 0),__decorate$7([n$8({type:Number,attribute:"shadow-intensity"})],EnvironmentModelViewerElement.prototype,"shadowIntensity",void 0),__decorate$7([n$8({type:Number,attribute:"shadow-softness"})],EnvironmentModelViewerElement.prototype,"shadowSoftness",void 0),__decorate$7([n$8({type:Number})],EnvironmentModelViewerElement.prototype,"exposure",void 0),EnvironmentModelViewerElement})((e=>{var t,i,n,r,a,o,l,c,h,d,A,p,m,g,f,v,E;class ControlsModelViewerElement extends e{constructor(){super(...arguments),this.cameraControls=!1,this.cameraOrbit=yl,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=Sl,this.interactionPromptStyle=Ml,this.orbitSensitivity=1,this.touchAction=bl,this.disableZoom=!1,this.disablePan=!1,this.disableTap=!1,this.interpolationDecay=50,this[t]=this.shadowRoot.querySelector(".interaction-prompt"),this[i]=this.shadowRoot.querySelector("#prompt"),this[n]=[this.shadowRoot.querySelector("#finger0"),this.shadowRoot.querySelector("#finger1")],this[r]=this.shadowRoot.querySelector(".pan-target"),this[a]=0,this[o]=1/0,this[l]=!1,this[c]=!1,this[h]=uc.AUTOMATIC,this[d]=new SmoothControls(this[sd].camera,this[nd],this[sd]),this[A]=new Spherical,this[p]=!1,this[m]=!1,this[g]=!1,this[f]=()=>{const e=this[Ll].changeSource;this[Xl]=e,e===uc.USER_INTERACTION&&(this[zl]=!0,this[Nl]())},this[v]=()=>{this[Ql](),this[ad]();const e=this[Ll].changeSource;this.dispatchEvent(new CustomEvent("camera-change",{detail:{source:e}}))},this[E]=e=>{"pointer-change-start"===e.type?this[id].classList.add("pointer-tumbling"):this[id].classList.remove("pointer-tumbling")}}get inputSensitivity(){return this[Ll].inputSensitivity}set inputSensitivity(e){this[Ll].inputSensitivity=e}getCameraOrbit(){const{theta:e,phi:t,radius:i}=this[jl];return{theta:e,phi:t,radius:i,toString(){return`${this.theta}rad ${this.phi}rad ${this.radius}m`}}}getCameraTarget(){return toVector3D(this[hd].isPresenting?this[hd].arRenderer.target:this[sd].getTarget())}getFieldOfView(){return this[Ll].getFieldOfView()}getMinimumFieldOfView(){return this[Ll].options.minimumFieldOfView}getMaximumFieldOfView(){return this[Ll].options.maximumFieldOfView}getIdealAspect(){return this[sd].idealAspect}jumpCameraToGoal(){this[Yl]=!0,this.requestUpdate(Yl,!1)}resetInteractionPrompt(){this[ql]=0,this[Wl]=1/0,this[zl]=!1,this[Hl]=this.interactionPrompt===Sl&&this.cameraControls}zoom(e){const t=new WheelEvent("wheel",{deltaY:-30*e});this[nd].dispatchEvent(t)}connectedCallback(){super.connectedCallback(),this[Ll].addEventListener("user-interaction",this[kl]),this[Ll].addEventListener("pointer-change-start",this[Vl]),this[Ll].addEventListener("pointer-change-end",this[Vl])}disconnectedCallback(){super.disconnectedCallback(),this[Ll].removeEventListener("user-interaction",this[kl]),this[Ll].removeEventListener("pointer-change-start",this[Vl]),this[Ll].removeEventListener("pointer-change-end",this[Vl])}updated(e){super.updated(e);const t=this[Ll],i=this[sd];if(e.has("cameraControls")&&(this.cameraControls?(t.enableInteraction(),this.interactionPrompt===Sl&&(this[Hl]=!0)):(t.disableInteraction(),this[Nl]()),this[nd].setAttribute("aria-label",this[Yu])),e.has("disableZoom")&&(t.disableZoom=this.disableZoom),e.has("disablePan")&&(t.enablePan=!this.disablePan),e.has("disableTap")&&(t.enableTap=!this.disableTap),(e.has("interactionPrompt")||e.has("cameraControls")||e.has("src"))&&(this.interactionPrompt===Sl&&this.cameraControls&&!this[zl]?this[Hl]=!0:this[Nl]()),e.has("interactionPromptStyle")&&(this[Pl].style.opacity=this.interactionPromptStyle==Cl?"1":"0"),e.has("touchAction")){const e=this.touchAction;t.applyOptions({touchAction:e}),t.updateTouchActionStyle()}e.has("orbitSensitivity")&&(t.orbitSensitivity=this.orbitSensitivity),e.has("interpolationDecay")&&(t.setDamperDecayTime(this.interpolationDecay),i.setTargetDamperDecayTime(this.interpolationDecay)),!0===this[Yl]&&Promise.resolve().then((()=>{t.jumpToGoal(),i.jumpToGoal(),this[Gl](),this[Yl]=!1}))}async updateFraming(){const e=this[sd],t=e.adjustedFoV(e.framedFoVDeg);await e.updateFraming();const i=e.adjustedFoV(e.framedFoVDeg),n=this[Ll].getFieldOfView()/t;this[Ll].setFieldOfView(i*n),this[$l]=!0,this.requestUpdate("maxFieldOfView"),this.requestUpdate("fieldOfView"),this.requestUpdate("minCameraOrbit"),this.requestUpdate("maxCameraOrbit"),this.requestUpdate("cameraOrbit"),await this.updateComplete}interact(e,t,i){const n=this[nd],r=this[Fl];if("1"===r[0].style.opacity)return void console.warn("interact() failed because an existing interaction is running.");const a=new Array;a.push({x:timeline(t.x),y:timeline(t.y)});const o=[{x:a[0].x(0),y:a[0].y(0)}];null!=i&&(a.push({x:timeline(i.x),y:timeline(i.y)}),o.push({x:a[1].x(0),y:a[1].y(0)}));let l=performance.now();const{width:c,height:h}=this[sd],d=this.getBoundingClientRect(),dispatchTouches=e=>{for(const[t,i]of o.entries()){const{style:a}=r[t];a.transform=`translateX(${c*i.x}px) translateY(${h*i.y}px)`,"pointerdown"===e?a.opacity="1":"pointerup"===e&&(a.opacity="0");const o={pointerId:t-5678,pointerType:"touch",target:n,clientX:c*i.x+d.x,clientY:h*i.y+d.y,altKey:!0};n.dispatchEvent(new PointerEvent(e,o))}},moveTouches=()=>{const t=this[Xl];if(t!==uc.AUTOMATIC||!n.isConnected){for(const e of this[Fl])e.style.opacity="0";return dispatchTouches("pointercancel"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:t}})),void document.removeEventListener("visibilitychange",onVisibilityChange)}const i=Math.min(1,(performance.now()-l)/e);for(const[e,t]of o.entries())t.x=a[e].x(i),t.y=a[e].y(i);dispatchTouches("pointermove"),i<1?requestAnimationFrame(moveTouches):(dispatchTouches("pointerup"),this.dispatchEvent(new CustomEvent("interact-stopped",{detail:{source:uc.AUTOMATIC}})),document.removeEventListener("visibilitychange",onVisibilityChange))},onVisibilityChange=()=>{let e=0;"hidden"===document.visibilityState?e=performance.now()-l:l=performance.now()-e};document.addEventListener("visibilitychange",onVisibilityChange),dispatchTouches("pointerdown"),this[Xl]=uc.AUTOMATIC,requestAnimationFrame(moveTouches)}[(t=Ul,i=Pl,n=Fl,r=Dl,a=ql,o=Wl,l=zl,c=Hl,h=Xl,d=Ll,A=jl,p=Yl,m=Kl,g=$l,Zl)](e){const t=this[Ll],i=this[sd];i.framedFoVDeg=180*e[0]/Math.PI,t.changeSource=uc.NONE,t.setFieldOfView(i.adjustedFoV(i.framedFoVDeg)),this[kl]()}[Jl](e){const t=this[Ll];if(this[$l]){const{theta:t,phi:i}=this.getCameraOrbit();e[0]=t,e[1]=i,this[$l]=!1}t.changeSource=uc.NONE,t.setOrbit(e[0],e[1],e[2]),this[kl]()}[tc](e){this[Ll].applyOptions({minimumAzimuthalAngle:e[0],minimumPolarAngle:e[1],minimumRadius:e[2]}),this.jumpCameraToGoal()}[ic](e){this[Ll].applyOptions({maximumAzimuthalAngle:e[0],maximumPolarAngle:e[1],maximumRadius:e[2]}),this[Ol](e[2]),this.jumpCameraToGoal()}[nc](e){this[Ll].applyOptions({minimumFieldOfView:180*e[0]/Math.PI}),this.jumpCameraToGoal()}[rc](e){const t=this[sd].adjustedFoV(180*e[0]/Math.PI);this[Ll].applyOptions({maximumFieldOfView:t}),this.jumpCameraToGoal()}[ec](e){const[t,i,n]=e;this[hd].arRenderer.isPresenting||this[sd].setTarget(t,i,n),this[Ll].changeSource=uc.NONE,this[hd].arRenderer.updateTarget(),this[kl]()}[od](e,t){if(super[od](e,t),this[hd].isPresenting||!this[Ad]())return;const i=this[Ll],n=this[sd],r=performance.now();if(this[Hl]&&this.loaded&&r>this[Zu]+this.interactionPromptThreshold&&(this[Hl]=!1,this[Wl]=r,this[Ul].classList.add("visible")),isFinite(this[Wl])&&this.interactionPromptStyle===Ml){const e=(r-this[Wl])/5e3%1,t=vl(e),a=El(e);if(this[Pl].style.opacity=`${a}`,t!==this[ql]){const e=t*n.width*.05,r=(t-this[ql])*Math.PI/16;this[Pl].style.transform=`translateX(${e}px)`,i.changeSource=uc.AUTOMATIC,i.adjustOrbit(r,0,0),this[ql]=t}}const a=i.update(e,t),o=n.updateTarget(t);(a||o)&&this[Gl]()}[Nl](){this[Hl]=!1,this[Ul].classList.remove("visible"),this[Wl]=1/0}[Ol](e){const t=Math.max(this[sd].boundingSphere.radius,e),i=Math.abs(2*t);this[Ll].updateNearFar(0,i)}[Ql](){const{theta:e,phi:t}=this[Ll].getCameraSpherical(this[jl]),i=(4+Math.floor((e%Rl+Bl)/wl))%4,n=Math.floor(t/Tl),r=_l[i],a=xl[n];this[Ju](`View from stage ${a}${r}`)}get[Yu](){return super[Yu].replace(/\.$/,"")+(this.cameraControls?". Use mouse, touch or arrow keys to move.":"")}async[cd](e){const t=this[Ll],i=this[sd],n=i.adjustedFoV(i.framedFoVDeg);super[cd](e);const r=i.adjustedFoV(i.framedFoVDeg)/n,a=t.getFieldOfView()*(isFinite(r)?r:1);t.updateAspect(this[sd].aspect),this.requestUpdate("maxFieldOfView",this.maxFieldOfView),await this.updateComplete,this[Ll].setFieldOfView(a),this.jumpCameraToGoal()}[ld](){super[ld](),this[Kl]?this[$l]=!0:this[Kl]=!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 f=kl,v=Gl,E=Vl,__decorate$6([n$8({type:Boolean,attribute:"camera-controls"})],ControlsModelViewerElement.prototype,"cameraControls",void 0),__decorate$6([style({intrinsics:Il,observeEffects:!0,updateHandler:Jl}),n$8({type:String,attribute:"camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"cameraOrbit",void 0),__decorate$6([style({intrinsics:cameraTargetIntrinsics,observeEffects:!0,updateHandler:ec}),n$8({type:String,attribute:"camera-target",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"cameraTarget",void 0),__decorate$6([style({intrinsics:fieldOfViewIntrinsics,observeEffects:!0,updateHandler:Zl}),n$8({type:String,attribute:"field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"fieldOfView",void 0),__decorate$6([style({intrinsics:minCameraOrbitIntrinsics,updateHandler:tc}),n$8({type:String,attribute:"min-camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"minCameraOrbit",void 0),__decorate$6([style({intrinsics:maxCameraOrbitIntrinsics,updateHandler:ic}),n$8({type:String,attribute:"max-camera-orbit",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"maxCameraOrbit",void 0),__decorate$6([style({intrinsics:minFieldOfViewIntrinsics,updateHandler:nc}),n$8({type:String,attribute:"min-field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"minFieldOfView",void 0),__decorate$6([style({intrinsics:fieldOfViewIntrinsics,updateHandler:rc}),n$8({type:String,attribute:"max-field-of-view",hasChanged:()=>!0})],ControlsModelViewerElement.prototype,"maxFieldOfView",void 0),__decorate$6([n$8({type:Number,attribute:"interaction-prompt-threshold"})],ControlsModelViewerElement.prototype,"interactionPromptThreshold",void 0),__decorate$6([n$8({type:String,attribute:"interaction-prompt"})],ControlsModelViewerElement.prototype,"interactionPrompt",void 0),__decorate$6([n$8({type:String,attribute:"interaction-prompt-style"})],ControlsModelViewerElement.prototype,"interactionPromptStyle",void 0),__decorate$6([n$8({type:Number,attribute:"orbit-sensitivity"})],ControlsModelViewerElement.prototype,"orbitSensitivity",void 0),__decorate$6([n$8({type:String,attribute:"touch-action"})],ControlsModelViewerElement.prototype,"touchAction",void 0),__decorate$6([n$8({type:Boolean,attribute:"disable-zoom"})],ControlsModelViewerElement.prototype,"disableZoom",void 0),__decorate$6([n$8({type:Boolean,attribute:"disable-pan"})],ControlsModelViewerElement.prototype,"disablePan",void 0),__decorate$6([n$8({type:Boolean,attribute:"disable-tap"})],ControlsModelViewerElement.prototype,"disableTap",void 0),__decorate$6([n$8({type:Number,attribute:"interpolation-decay"})],ControlsModelViewerElement.prototype,"interpolationDecay",void 0),ControlsModelViewerElement})((e=>{var t,i,n,r,a,o,l,c,h,d;class ARModelViewerElement extends e{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[t]=!1,this[i]=this.shadowRoot.querySelector(".ar-button"),this[n]=document.createElement("a"),this[r]=new Set,this[a]=tA,this[o]=!1,this[l]=e=>{e.preventDefault(),this.activateAR()},this[c]=({status:e})=>{e!==Ac&&this[hd].arRenderer.presentedScene!==this[sd]||(this.setAttribute("ar-status",e),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:e}})),e===Ac?this.removeAttribute("ar-tracking"):e===pc&&this.setAttribute("ar-tracking",fc))},this[h]=({status:e})=>{this.setAttribute("ar-tracking",e),this.dispatchEvent(new CustomEvent("ar-tracking",{detail:{status:e}}))},this[d]=e=>{"_apple_ar_quicklook_button_tapped"==e.data&&this.dispatchEvent(new CustomEvent("quick-look-button-tapped"))}}get canActivateAR(){return this[oA]!==tA}connectedCallback(){super.connectedCallback(),this[hd].arRenderer.addEventListener("status",this[dA]),this.setAttribute("ar-status",Ac),this[hd].arRenderer.addEventListener("tracking",this[AA]),this[cA].addEventListener("message",this[pA])}disconnectedCallback(){super.disconnectedCallback(),this[hd].arRenderer.removeEventListener("status",this[dA]),this[hd].arRenderer.removeEventListener("tracking",this[AA]),this[cA].removeEventListener("message",this[pA])}update(e){super.update(e),e.has("arScale")&&(this[sd].canScale="fixed"!==this.arScale),e.has("arPlacement")&&(this[sd].updateShadow(),this[ad]()),e.has("arModes")&&(this[lA]=Kd(this.arModes)),(e.has("ar")||e.has("arModes")||e.has("src")||e.has("iosSrc"))&&this[mA]()}async activateAR(){switch(this[oA]){case Jd:await this[sA]();break;case eA:await this[nA]();break;case Zd:this[rA]();break;default:console.warn("No AR Mode can be activated. This is probably due to missing configuration or device capabilities")}}async[(t=aA,i=iA,n=cA,r=lA,a=oA,o=hA,l=uA,c=dA,h=AA,d=pA,mA)](){let e=tA;if(this.ar){if(null!=this.src)for(const t of this[lA]){if("webxr"===t&&Ms&&!Xd&&await this[hd].arRenderer.supportsPresentation()){e=eA;break}if("scene-viewer"===t&&Bs&&!jd){e=Zd;break}if("quick-look"===t&&Ls){e=Jd;break}}e===tA&&null!=this.iosSrc&&Ls&&(e=Jd)}if(e!==tA)this[iA].classList.add("enabled"),this[iA].addEventListener("click",this[uA]);else if(this[iA].classList.contains("enabled")){this[iA].removeEventListener("click",this[uA]),this[iA].classList.remove("enabled");const e=gc;this.setAttribute("ar-status",e),this.dispatchEvent(new CustomEvent("ar-status",{detail:{status:e}}))}this[oA]=e}async[nA](){console.log("Attempting to present in AR with WebXR..."),await this[gA]();try{this[iA].removeEventListener("click",this[uA]);const{arRenderer:e}=this[hd];e.placeOnWall="wall"===this.arPlacement,await e.present(this[sd],this.xrEnvironment)}catch(e){console.warn("Error while trying to present in AR with WebXR"),console.error(e),await this[hd].arRenderer.stopPresenting(),Xd=!0,console.warn("Falling back to next ar-mode"),await this[mA](),this.activateAR()}finally{this[mA]()}}async[gA](){this.loaded||(this[hA]=!0,this[ed](),await((e,t,i=null)=>new Promise((n=>{e.addEventListener(t,(function handler(r){i&&!i(r)||(n(r),e.removeEventListener(t,handler))}))})))(this,"load"),this[hA]=!1)}[pd](){return super[pd]()||this[hA]}[rA](){const e=self.location.toString(),t=new URL(e),i=new URL(this.src,e);i.hash&&(i.hash="");const n=new URLSearchParams(i.search);if(t.hash=Yd,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 t=new URL(n.get("sound"),e);n.set("sound",t.toString())}if(n.has("link")){const t=new URL(n.get("link"),e);n.set("link",t.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(t.toString())};end;`;self.addEventListener("hashchange",(()=>{self.location.hash===Yd&&(jd=!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[mA]())}),{once:!0}),this[cA].setAttribute("href",r),console.log("Attempting to present in AR with Scene Viewer..."),this[cA].click()}async[sA](){const e=!this.iosSrc;this[iA].classList.remove("enabled");const t=e?await this.prepareUSDZ():this.iosSrc,i=new URL(t,self.location.toString());if(e){const e=self.location.toString(),t=new URL(e),n=new URL(this.src,t);n.hash&&(i.hash=n.hash)}"fixed"===this.arScale&&(i.hash&&(i.hash+="&"),i.hash+="allowsContentScaling=0");const n=this[cA];n.setAttribute("rel","ar");const r=document.createElement("img");n.appendChild(r),n.setAttribute("href",i.toString()),e&&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),e&&URL.revokeObjectURL(t),this[iA].classList.add("enabled")}async prepareUSDZ(){const e=this[ud].beginActivity();await this[gA]();const{model:t,shadow:i}=this[sd];if(null==t)return"";let n=!1;null!=i&&(n=i.visible,i.visible=!1),e(.2);const r=new USDZExporter,a=await r.parse(t),o=new Blob([a],{type:"model/vnd.usdz+zip"}),l=URL.createObjectURL(o);return e(1),null!=i&&(i.visible=n),l}}return __decorate$2([n$8({type:Boolean,attribute:"ar"})],ARModelViewerElement.prototype,"ar",void 0),__decorate$2([n$8({type:String,attribute:"ar-scale"})],ARModelViewerElement.prototype,"arScale",void 0),__decorate$2([n$8({type:String,attribute:"ar-placement"})],ARModelViewerElement.prototype,"arPlacement",void 0),__decorate$2([n$8({type:String,attribute:"ar-modes"})],ARModelViewerElement.prototype,"arModes",void 0),__decorate$2([n$8({type:String,attribute:"ios-src"})],ARModelViewerElement.prototype,"iosSrc",void 0),__decorate$2([n$8({type:Boolean,attribute:"xr-environment"})],ARModelViewerElement.prototype,"xrEnvironment",void 0),ARModelViewerElement})((e=>{var t,i,n,r,a,o,l,c;class LoadingModelViewerElement extends e{constructor(...e){super(...e),this.poster=null,this.reveal=fA,this.loading=vA,this[t]=!1,this[i]=!1,this[n]=this.shadowRoot.querySelector(".slot.poster"),this[r]=this.shadowRoot.querySelector("#default-poster"),this[a]=this.shadowRoot.querySelector("#default-progress-bar > .bar"),this[o]=this[xA].getAttribute("aria-label"),this[l]=((e,t)=>{let i=null;const throttled=(...n)=>{null==i&&(e(...n),i=self.setTimeout((()=>i=null),t))};return throttled.flush=()=>{null!=i&&(self.clearTimeout(i),i=null)},throttled})((e=>{const t=this[yA].parentNode;requestAnimationFrame((()=>{this[yA].style.transform=`scaleX(${e})`,0===e&&(t.removeChild(this[yA]),t.appendChild(this[yA])),1===e?this[yA].classList.add("hide"):this[yA].classList.remove("hide")}))}),100),this[c]=e=>{const t=e.detail.totalProgress;1===t&&(this[bA].flush(),this.loaded&&(this[SA]||this.reveal===fA)&&this[CA]()),this[bA](t),this.dispatchEvent(new CustomEvent("progress",{detail:{totalProgress:t}}))};const h=self.ModelViewerElement||{},d=h.dracoDecoderLocation||"https://www.gstatic.com/draco/versioned/decoders/1.5.6/";CachingGLTFLoader.setDRACODecoderLocation(d);const A=h.ktx2TranscoderLocation||"https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";CachingGLTFLoader.setKTX2TranscoderLocation(A),h.meshoptDecoderLocation&&CachingGLTFLoader.setMeshoptDecoderLocation(h.meshoptDecoderLocation);const p=h.lottieLoaderLocation||"https://cdn.jsdelivr.net/npm/three@0.149.0/examples/jsm/loaders/LottieLoader.js";Renderer.singleton.textureUtils.lottieLoaderUrl=p}static set dracoDecoderLocation(e){CachingGLTFLoader.setDRACODecoderLocation(e)}static get dracoDecoderLocation(){return CachingGLTFLoader.getDRACODecoderLocation()}static set ktx2TranscoderLocation(e){CachingGLTFLoader.setKTX2TranscoderLocation(e)}static get ktx2TranscoderLocation(){return CachingGLTFLoader.getKTX2TranscoderLocation()}static set meshoptDecoderLocation(e){CachingGLTFLoader.setMeshoptDecoderLocation(e)}static get meshoptDecoderLocation(){return CachingGLTFLoader.getMeshoptDecoderLocation()}static set lottieLoaderLocation(e){Renderer.singleton.textureUtils.lottieLoaderUrl=e}static get lottieLoaderLocation(){return Renderer.singleton.textureUtils.lottieLoaderUrl}static mapURLs(e){Renderer.singleton.loader[Wa].manager.setURLModifier(e)}dismissPoster(){this.loaded?this[CA]():(this[SA]=!0,this[ed]())}showPoster(){const e=this[_A];if(e.classList.contains("show"))return;e.classList.add("show"),this[nd].classList.remove("show");const t=this[xA];t.removeAttribute("tabindex"),t.removeAttribute("aria-hidden");const i=this.modelIsVisible;this[MA]=!1,this[ju](i)}getDimensions(){return toVector3D(this[sd].size)}getBoundingBoxCenter(){return toVector3D(this[sd].boundingBox.getCenter(new Vector3))}connectedCallback(){super.connectedCallback(),this.loaded||this.showPoster(),this[ud].addEventListener("progress",this[wA])}disconnectedCallback(){super.disconnectedCallback(),this[ud].removeEventListener("progress",this[wA])}async updated(e){super.updated(e),e.has("poster")&&null!=this.poster&&(this[xA].style.backgroundImage=`url(${this.poster})`),e.has("alt")&&this[xA].setAttribute("aria-label",this[Ku]),(e.has("reveal")||e.has("loading"))&&this[ed]()}[(t=MA,i=SA,n=_A,r=xA,a=yA,o=IA,l=bA,c=wA,pd)](){return!!this.src&&(this[SA]||this.loading===EA||this.reveal===fA&&this[Xu])}[CA](){this[SA]=!1;const e=this[_A];if(!e.classList.contains("show"))return;e.classList.remove("show"),this[nd].classList.add("show");const t=this.modelIsVisible;this[MA]=!0,this[ju](t);const i=this.getRootNode();i&&i.activeElement===this&&this[nd].focus();const n=this[xA];n.setAttribute("aria-hidden","true"),n.tabIndex=-1,this.dispatchEvent(new CustomEvent("poster-dismissed"))}[Ad](){return super[Ad]()&&this[MA]}}return __decorate$1([n$8({type:String})],LoadingModelViewerElement.prototype,"poster",void 0),__decorate$1([n$8({type:String})],LoadingModelViewerElement.prototype,"reveal",void 0),__decorate$1([n$8({type:String})],LoadingModelViewerElement.prototype,"loading",void 0),LoadingModelViewerElement})((e=>{var t;class AnimationModelViewerElement extends e{constructor(...e){super(e),this.autoplay=!1,this.animationName=void 0,this.animationCrossfadeDuration=300,this[t]=!0,this[sd].subscribeMixerEvent("loop",(e=>{const t=e.action._loopCount;this.dispatchEvent(new CustomEvent("loop",{detail:{count:t}}))})),this[sd].subscribeMixerEvent("finished",(()=>{this[gd]=!0,this.dispatchEvent(new CustomEvent("finished"))}))}get availableAnimations(){return this.loaded?this[sd].animationNames:[]}get duration(){return this[sd].duration}get paused(){return this[gd]}get currentTime(){return this[sd].animationTime}set currentTime(e){this[sd].animationTime=e,this[ad]()}get timeScale(){return this[sd].animationTimeScale}set timeScale(e){this[sd].animationTimeScale=e}pause(){this[gd]||(this[gd]=!0,this.dispatchEvent(new CustomEvent("pause")))}play(e){this.availableAnimations.length>0&&(this[gd]=!1,this[md](e),this.dispatchEvent(new CustomEvent("play")))}[(t=gd,ld)](){super[ld](),this[gd]=!0,null!=this.animationName&&this[md](),this.autoplay&&this.play()}[od](e,t){super[od](e,t),this[gd]||!this[Ad]()&&!this[hd].isPresenting||(this[sd].updateAnimation(t/1e3),this[ad]())}updated(e){super.updated(e),e.has("autoplay")&&this.autoplay&&this.play(),e.has("animationName")&&this[md]()}[md](e=fd){var t;const i=null!==(t=e.repetitions)&&void 0!==t?t:1/0,n=e.pingpong?ge:1===i?2200:me;this[sd].playAnimation(this.animationName,this.animationCrossfadeDuration/1e3,n,i),this[gd]&&(this[sd].updateAnimation(0),this[ad]())}}return __decorate$3([n$8({type:Boolean})],AnimationModelViewerElement.prototype,"autoplay",void 0),__decorate$3([n$8({type:String,attribute:"animation-name"})],AnimationModelViewerElement.prototype,"animationName",void 0),__decorate$3([n$8({type:Number,attribute:"animation-crossfade-duration"})],AnimationModelViewerElement.prototype,"animationCrossfadeDuration",void 0),AnimationModelViewerElement})(ModelViewerElementBase))))))));customElements.define("model-viewer",PA);export{CanvasTexture,FileLoader,Loader,PA as ModelViewerElement,B as NearestFilter};