diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..6e0a0c6 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,223 @@ +module.exports = { + env: { + browser: true, + es2021: true + }, + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended" + ], + parser: "@typescript-eslint/parser", + parserOptions: { + project: ["./src/client/tsconfig.json", "./src/server/tsconfig.json"], + ecmaVersion: "latest", + sourceType: "module", + }, + plugins: [ + "@typescript-eslint", + "prettier" + ], + ignorePatterns: [ + "*.glb", + "*.json", + "*.env", + "*.envmap", + "*.exr", + "beta/**/*", + "dist/**/*", + "patches/**/*", + "resources/**/*", + "src/client/webpack.*.js", + "/*.js" + ], + rules: { + "no-console": "off", + "no-prototype-builtins": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/array-type": ["error", { default: "array-simple" }], + "@typescript-eslint/ban-types": [ + "error", + { + types: { + Object: { + message: "Avoid using the `Object` type. Did you mean `object`?", + }, + Function: { + message: + "Avoid using the `Function` type. Prefer a specific function type, like `() => void`.", + }, + Boolean: { + message: "Avoid using the `Boolean` type. Did you mean `boolean`?", + }, + Number: { + message: "Avoid using the `Number` type. Did you mean `number`?", + }, + String: { + message: "Avoid using the `String` type. Did you mean `string`?", + }, + Symbol: { + message: "Avoid using the `Symbol` type. Did you mean `symbol`?", + }, + }, + }, + ], + "@typescript-eslint/consistent-type-definitions": "error", + "@typescript-eslint/dot-notation": "error", + "@typescript-eslint/member-delimiter-style": [ + "error", + { + multiline: { delimiter: "semi", requireLast: true }, + singleline: { delimiter: "semi", requireLast: false }, + }, + ], + "@typescript-eslint/no-unused-expressions": "error", + "@typescript-eslint/prefer-for-of": "error", + "@typescript-eslint/prefer-function-type": "error", + "@typescript-eslint/quotes": ["error", "single"], + "@typescript-eslint/semi": ["error", "always"], + "@typescript-eslint/triple-slash-reference": [ + "error", + { + path: "always", + types: "prefer-import", + lib: "always", + }, + ], + "@typescript-eslint/unified-signatures": "error", + "arrow-parens": ["error", "always"], + camelcase: "error", + complexity: ["error", { max: 13 }], + "constructor-super": "error", + curly: "error", + "eol-last": "error", + eqeqeq: ["error", "smart"], + "for-direction": "error", + "getter-return": "error", + "id-match": "error", + "new-parens": "error", + "no-async-promise-executor": "error", + "no-caller": "error", + "no-case-declarations": "error", + "no-class-assign": "error", + "no-compare-neg-zero": "error", + "no-cond-assign": "error", + "no-const-assign": "error", + "no-constant-condition": "error", + "no-control-regex": "error", + "no-debugger": "error", + "no-delete-var": "error", + "no-dupe-args": "error", + "no-dupe-class-members": "error", + "no-dupe-else-if": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-empty": "error", + "no-empty-character-class": "error", + "no-empty-pattern": "error", + "no-eval": "error", + "no-ex-assign": "error", + "no-extra-boolean-cast": "error", + "no-extra-semi": "error", + "no-func-assign": "error", + "no-global-assign": "error", + "no-import-assign": "error", + "no-inner-declarations": "error", + "no-invalid-regexp": "error", + "no-irregular-whitespace": "error", + "no-misleading-character-class": "error", + "no-mixed-spaces-and-tabs": "error", + "no-multiple-empty-lines": "error", + "no-new-symbol": "error", + "no-new-wrappers": "error", + "no-obj-calls": "error", + "no-octal": "error", + "no-redeclare": "error", + "no-regex-spaces": "error", + "no-self-assign": "error", + "no-setter-return": "error", + // 'no-shadow': ['error', {'hoist': 'all'}], --> see why we commented it: https://github.com/typescript-eslint/typescript-eslint/issues/2483#issuecomment-687095358 + "no-shadow-restricted-names": "error", + "no-sparse-arrays": "error", + "no-this-before-super": "error", + "no-throw-literal": "error", + "no-trailing-spaces": "error", + "no-undef": "error", + "no-undef-init": "error", + "no-underscore-dangle": 0, + "no-unexpected-multiline": "error", + "no-unreachable": "error", + "no-unsafe-finally": "error", + "no-unsafe-negation": "error", + "no-unused-labels": "error", + "no-useless-catch": "error", + "no-with": "error", + "object-shorthand": "error", + "one-var": ["error", "never"], + "quote-props": ["error", "consistent-as-needed"], + radix: "error", + "require-yield": "error", + "space-before-function-paren": [ + "error", + { anonymous: "always", named: "never", asyncArrow: "always" }, + ], + "use-isnan": "error", + "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], + "@typescript-eslint/ban-ts-comment": [ + "warn", + { + "ts-ignore": { descriptionFormat: "^ -- " }, + "ts-nocheck": { descriptionFormat: "^ -- " }, + }, + ], + "@typescript-eslint/no-shadow": "error", + "@typescript-eslint/consistent-type-imports": [ + "error", + { + prefer: "type-imports", + disallowTypeAnnotations: true, + fixStyle: "separate-type-imports", + }, + ], + }, + overrides: [ + { + env: { + node: true + }, + files: [ + ".eslintrc.{js,cjs}" + ], + parserOptions: { + "sourceType": "script" + } + }, + { + env: { + node: true + }, + files: [ + "src/server/**/*.ts" + ], + parserOptions: { + "sourceType": "module" + } + }, + { + files: [ + "src/client/drag_target.ts", + ], + rules: { + "@typescript-eslint/ban-ts-comment": "off" + } + }, + { + files: [ + "src/client/experimental/outline_pass.ts", + ], + rules: { + "@typescript-eslint/prefer-for-of": "off" + } + } + ] + } + \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..f8affb5 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,15 @@ +.devcontainer +.vscode +beta +dist/client/**/*.js +dist/server +patches +resource +node_modules +built +output +src/client/wasm_interfaces/*.* +src/client/configurator/wasm/*.* +*.js +*.json +*.md \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..8738a1a --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "trailingComma": "es5" +} + \ No newline at end of file diff --git a/deploy/bundle.js b/deploy/bundle.js index d2c16e7..668d196 100644 --- a/deploy/bundle.js +++ b/deploy/bundle.js @@ -1,2 +1,2 @@ /*! For license information please see bundle.js.LICENSE.txt */ -(()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var n=e.g.document;if(!t&&n&&(n.currentScript&&(t=n.currentScript.src),!t)){var i=n.getElementsByTagName("script");if(i.length)for(var r=i.length-1;r>-1&&!t;)t=i[r--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})();const t=[{name:"BrainStem",url:"./BrainStem.glb"},{name:"DamagedHelmet",url:"./DamagedHelmet.glb"}],n="159",i=1,r=2,a=3,s=100,o=0,l=1,c=2,h=0,d=1,u=2,p=3,f=4,m=5,g="attached",v=301,_=302,x=306,y=1e3,S=1001,w=1002,b=1003,M=1004,T=1005,E=1006,A=1008,R=1009,C=1012,P=1014,L=1015,D=1016,I=1020,N=1023,O=1026,U=1027,F=1028,B=1030,z=33776,k=33777,H=33778,V=33779,G=36492,W=2300,j=2301,X=2302,Y=3001,q="",Z="srgb",K="srgb-linear",J="display-p3",Q="display-p3-linear",$="linear",ee="srgb",te="rec709",ne="p3",ie=7680,re=35044,ae="300 es",se=1035,oe=2e3,le=2001;class ce{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.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 n=t.slice(0);for(let t=0,i=n.length;t>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&n|128]+he[n>>8&255]+"-"+he[n>>16&255]+he[n>>24&255]+he[255&i]+he[i>>8&255]+he[i>>16&255]+he[i>>24&255]).toLowerCase()}function me(e,t,n){return Math.max(t,Math.min(n,e))}function ge(e,t){return(e%t+t)%t}function ve(e,t,n){return(1-n)*e+n*t}function _e(e){return 0==(e&e-1)&&0!==e}function xe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function ye(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 Se(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 we={DEG2RAD:ue,RAD2DEG:pe,generateUUID:fe,clamp:me,euclideanModulo:ge,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:ve,damp:function(e,t,n,i){return ve(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(ge(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(de=e);let t=de+=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(e){return e*ue},radToDeg:function(e){return e*pe},isPowerOfTwo:_e,ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:xe,setQuaternionFromProperEuler:function(e,t,n,i,r){const a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),c=a((t+i)/2),h=s((t+i)/2),d=a((t-i)/2),u=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*h,l*d,l*u,o*c);break;case"YZY":e.set(l*u,o*h,l*d,o*c);break;case"ZXZ":e.set(l*d,l*u,o*h,o*c);break;case"XZX":e.set(o*h,l*f,l*p,o*c);break;case"YXY":e.set(l*p,o*h,l*f,o*c);break;case"ZYZ":e.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Se,denormalize:ye};class be{constructor(e=0,t=0){be.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(me(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Me{constructor(e,t,n,i,r,a,s,o,l){Me.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=s,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],c=n[4],h=n[7],d=n[2],u=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],x=i[7],y=i[2],S=i[5],w=i[8];return r[0]=a*f+s*v+o*y,r[3]=a*m+s*_+o*S,r[6]=a*g+s*x+o*w,r[1]=l*f+c*v+h*y,r[4]=l*m+c*_+h*S,r[7]=l*g+c*x+h*w,r[2]=d*f+u*v+p*y,r[5]=d*m+u*_+p*S,r[8]=d*g+u*x+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8];return t*a*c-t*s*l-n*r*c+n*s*o+i*r*l-i*a*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=c*a-s*l,d=s*o-c*r,u=l*r-a*o,p=t*h+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=h*f,e[1]=(i*l-c*n)*f,e[2]=(s*n-i*a)*f,e[3]=d*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=u*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(Te.makeScale(e,t)),this}rotate(e){return this.premultiply(Te.makeRotation(-e)),this}translate(e,t){return this.premultiply(Te.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Te=new Me;function Ee(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Ae(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Re(){const e=Ae("canvas");return e.style.display="block",e}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;const Ce={};function Pe(e){e in Ce||(Ce[e]=!0,console.warn(e))}const Le=(new Me).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),De=(new Me).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ie={[K]:{transfer:$,primaries:te,toReference:e=>e,fromReference:e=>e},[Z]:{transfer:ee,primaries:te,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[Q]:{transfer:$,primaries:ne,toReference:e=>e.applyMatrix3(De),fromReference:e=>e.applyMatrix3(Le)},[J]:{transfer:ee,primaries:ne,toReference:e=>e.convertSRGBToLinear().applyMatrix3(De),fromReference:e=>e.applyMatrix3(Le).convertLinearToSRGB()}},Ne=new Set([K,Q]),Oe={enabled:!0,_workingColorSpace:K,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 this._workingColorSpace},set workingColorSpace(e){if(!Ne.has(e))throw new Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const i=Ie[t].toReference;return(0,Ie[n].fromReference)(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return Ie[e].primaries},getTransfer:function(e){return e===q?$:Ie[e].transfer}};function Ue(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Fe(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let Be;class ze{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===Be&&(Be=Ae("canvas")),Be.width=e.width,Be.height=e.height;const n=Be.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Be}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=Ae("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}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 y:e.x=e.x-Math.floor(e.x);break;case S:e.x=e.x<0?0:1;break;case w: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 y:e.y=e.y-Math.floor(e.y);break;case S:e.y=e.y<0?0:1;break;case w: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 Pe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Z?Y:3e3}set encoding(e){Pe("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Y?Z:q}}We.DEFAULT_IMAGE=null,We.DEFAULT_MAPPING=300,We.DEFAULT_ANISOTROPY=1;class je{constructor(e=0,t=0,n=0,i=1){je.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=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,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+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,n,i,r;const a=.01,s=.1,o=e.elements,l=o[0],c=o[4],h=o[8],d=o[1],u=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-d)o&&e>v?ev?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}const r=s*n;if(o=o*e+d*r,l=l*e+u*r,c=c*e+p*r,h=h*e+f*r,e===1-s){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const s=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[a],d=r[a+1],u=r[a+2],p=r[a+3];return e[t]=s*p+c*h+o*u-l*d,e[t+1]=o*p+c*d+l*h-s*u,e[t+2]=l*p+c*u+s*d-o*h,e[t+3]=c*p-s*h-o*d-l*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),c=s(i/2),h=s(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"YXZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"ZXY":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"ZYX":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"YZX":this._x=d*c*h+l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h-d*u*p;break;case"XZY":this._x=d*c*h-l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],c=t[6],h=t[10],d=n+s+h;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>h){const e=2*Math.sqrt(1+n-s-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>h){const e=2*Math.sqrt(1+s-n-h);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(me(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 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 n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+a*s+i*l-r*o,this._y=i*c+a*o+r*s-n*l,this._z=r*c+a*l+n*o-i*s,this._w=a*c-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let s=a*e._w+n*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const o=1-s*s;if(o<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,s),h=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}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 Je{constructor(e=0,t=0,n=0){Je.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion($e.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion($e.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),c=2*(s*t-r*i),h=2*(r*n-a*t);return this.x=t+o*l+a*h-s*c,this.y=n+o*c+s*l-r*h,this.z=i+o*h+r*c-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Qe.copy(this).projectOnVector(e),this.sub(Qe)}reflect(e){return this.sub(Qe.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 n=this.dot(e)/t;return Math.acos(me(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,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,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Qe=new Je,$e=new Ke;class et{constructor(e=new Je(1/0,1/0,1/0),t=new Je(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,nt),nt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ht),dt.subVectors(this.max,ht),rt.subVectors(e.a,ht),at.subVectors(e.b,ht),st.subVectors(e.c,ht),ot.subVectors(at,rt),lt.subVectors(st,at),ct.subVectors(rt,st);let t=[0,-ot.z,ot.y,0,-lt.z,lt.y,0,-ct.z,ct.y,ot.z,0,-ot.x,lt.z,0,-lt.x,ct.z,0,-ct.x,-ot.y,ot.x,0,-lt.y,lt.x,0,-ct.y,ct.x,0];return!!ft(t,rt,at,st,dt)&&(t=[1,0,0,0,1,0,0,0,1],!!ft(t,rt,at,st,dt)&&(ut.crossVectors(ot,lt),t=[ut.x,ut.y,ut.z],ft(t,rt,at,st,dt)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,nt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(nt).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()||(tt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),tt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),tt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),tt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),tt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),tt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),tt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),tt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(tt)),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 tt=[new Je,new Je,new Je,new Je,new Je,new Je,new Je,new Je],nt=new Je,it=new et,rt=new Je,at=new Je,st=new Je,ot=new Je,lt=new Je,ct=new Je,ht=new Je,dt=new Je,ut=new Je,pt=new Je;function ft(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){pt.fromArray(e,a);const s=r.x*Math.abs(pt.x)+r.y*Math.abs(pt.y)+r.z*Math.abs(pt.z),o=t.dot(pt),l=n.dot(pt),c=i.dot(pt);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>s)return!1}return!0}const mt=new et,gt=new Je,vt=new Je;class _t{constructor(e=new Je,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):mt.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.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;gt.subVectors(e,this.center);const t=gt.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(gt,n/e),this.radius+=n}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):(vt.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gt.copy(e.center).add(vt)),this.expandByPoint(gt.copy(e.center).sub(vt))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const xt=new Je,yt=new Je,St=new Je,wt=new Je,bt=new Je,Mt=new Je,Tt=new Je;class Et{constructor(e=new Je,t=new Je(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 n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=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,n,i){yt.copy(e).add(t).multiplyScalar(.5),St.copy(t).sub(e).normalize(),wt.copy(this.origin).sub(yt);const r=.5*e.distanceTo(t),a=-this.direction.dot(St),s=wt.dot(this.direction),o=-wt.dot(St),l=wt.lengthSq(),c=Math.abs(1-a*a);let h,d,u,p;if(c>0)if(h=a*o-s,d=a*s-o,p=r*c,h>=0)if(d>=-p)if(d<=p){const e=1/c;h*=e,d*=e,u=h*(h+a*d+2*s)+d*(a*h+d+2*o)+l}else d=r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d=-r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d<=-p?(h=Math.max(0,-(-a*r+s)),d=h>0?-r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l):d<=p?(h=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(h=Math.max(0,-(a*r+s)),d=h>0?r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l);else d=a>0?-r:r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(yt).addScaledVector(St,d),u}intersectSphere(e,t){xt.subVectors(e.center,this.origin);const n=xt.dot(this.direction),i=xt.dot(xt)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),c>=0?(r=(e.min.y-d.y)*c,a=(e.max.y-d.y)*c):(r=(e.max.y-d.y)*c,a=(e.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-d.z)*h,o=(e.max.z-d.z)*h):(s=(e.max.z-d.z)*h,o=(e.min.z-d.z)*h),n>o||s>i?null:((s>n||n!=n)&&(n=s),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,xt)}intersectTriangle(e,t,n,i,r){bt.subVectors(t,e),Mt.subVectors(n,e),Tt.crossVectors(bt,Mt);let a,s=this.direction.dot(Tt);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}wt.subVectors(this.origin,e);const o=a*this.direction.dot(Mt.crossVectors(wt,Mt));if(o<0)return null;const l=a*this.direction.dot(bt.cross(wt));if(l<0)return null;if(o+l>s)return null;const c=-a*wt.dot(Tt);return c<0?null:this.at(c/s,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 At{constructor(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){At.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,n,i,r,a,s,o,l,c,h,d,u,p,f,m)}set(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=d,g[3]=u,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new At).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Rt.setFromMatrixColumn(e,0).length(),r=1/Rt.setFromMatrixColumn(e,1).length(),a=1/Rt.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*h,t[5]=a*c,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*s,t[4]=-a*h,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*c,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=a*c,t[9]=-s*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=a*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=s*c,t[10]=r*h+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(Pt,e,Lt)}lookAt(e,t,n){const i=this.elements;return Nt.subVectors(e,t),0===Nt.lengthSq()&&(Nt.z=1),Nt.normalize(),Dt.crossVectors(n,Nt),0===Dt.lengthSq()&&(1===Math.abs(n.z)?Nt.x+=1e-4:Nt.z+=1e-4,Nt.normalize(),Dt.crossVectors(n,Nt)),Dt.normalize(),It.crossVectors(Nt,Dt),i[0]=Dt.x,i[4]=It.x,i[8]=Nt.x,i[1]=Dt.y,i[5]=It.y,i[9]=Nt.y,i[2]=Dt.z,i[6]=It.z,i[10]=Nt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],c=n[1],h=n[5],d=n[9],u=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],x=n[11],y=n[15],S=i[0],w=i[4],b=i[8],M=i[12],T=i[1],E=i[5],A=i[9],R=i[13],C=i[2],P=i[6],L=i[10],D=i[14],I=i[3],N=i[7],O=i[11],U=i[15];return r[0]=a*S+s*T+o*C+l*I,r[4]=a*w+s*E+o*P+l*N,r[8]=a*b+s*A+o*L+l*O,r[12]=a*M+s*R+o*D+l*U,r[1]=c*S+h*T+d*C+u*I,r[5]=c*w+h*E+d*P+u*N,r[9]=c*b+h*A+d*L+u*O,r[13]=c*M+h*R+d*D+u*U,r[2]=p*S+f*T+m*C+g*I,r[6]=p*w+f*E+m*P+g*N,r[10]=p*b+f*A+m*L+g*O,r[14]=p*M+f*R+m*D+g*U,r[3]=v*S+_*T+x*C+y*I,r[7]=v*w+_*E+x*P+y*N,r[11]=v*b+_*A+x*L+y*O,r[15]=v*M+_*R+x*D+y*U,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],c=e[2],h=e[6],d=e[10],u=e[14];return e[3]*(+r*o*h-i*l*h-r*s*d+n*l*d+i*s*u-n*o*u)+e[7]*(+t*o*u-t*l*d+r*a*d-i*a*u+i*l*c-r*o*c)+e[11]*(+t*l*h-t*s*u-r*a*h+n*a*u+r*s*c-n*l*c)+e[15]*(-i*s*c-t*o*h+t*s*d+i*a*h-n*a*d+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=e[9],d=e[10],u=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=h*m*l-f*d*l+f*o*u-s*m*u-h*o*g+s*d*g,_=p*d*l-c*m*l-p*o*u+a*m*u+c*o*g-a*d*g,x=c*f*l-p*h*l+p*s*u-a*f*u-c*s*g+a*h*g,y=p*h*o-c*f*o-p*s*d+a*f*d+c*s*m-a*h*m,S=t*v+n*_+i*x+r*y;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/S;return e[0]=v*w,e[1]=(f*d*r-h*m*r-f*i*u+n*m*u+h*i*g-n*d*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(h*o*r-s*d*r-h*i*l+n*d*l+s*i*u-n*o*u)*w,e[4]=_*w,e[5]=(c*m*r-p*d*r+p*i*u-t*m*u-c*i*g+t*d*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*d*r-c*o*r+c*i*l-t*d*l-a*i*u+t*o*u)*w,e[8]=x*w,e[9]=(p*h*r-c*f*r-p*n*u+t*f*u+c*n*g-t*h*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(c*s*r-a*h*r-c*n*l+t*h*l+a*n*u-t*s*u)*w,e[12]=y*w,e[13]=(c*f*i-p*h*i+p*n*d-t*f*d-c*n*m+t*h*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*h*i-c*s*i+c*n*o-t*h*o-a*n*d+t*s*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,c=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,c*s+n,c*o-i*a,0,l*o-i*s,c*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,c=a+a,h=s+s,d=r*l,u=r*c,p=r*h,f=a*c,m=a*h,g=s*h,v=o*l,_=o*c,x=o*h,y=n.x,S=n.y,w=n.z;return i[0]=(1-(f+g))*y,i[1]=(u+x)*y,i[2]=(p-_)*y,i[3]=0,i[4]=(u-x)*S,i[5]=(1-(d+g))*S,i[6]=(m+v)*S,i[7]=0,i[8]=(p+_)*w,i[9]=(m-v)*w,i[10]=(1-(d+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Rt.set(i[0],i[1],i[2]).length();const a=Rt.set(i[4],i[5],i[6]).length(),s=Rt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Ct.copy(this);const o=1/r,l=1/a,c=1/s;return Ct.elements[0]*=o,Ct.elements[1]*=o,Ct.elements[2]*=o,Ct.elements[4]*=l,Ct.elements[5]*=l,Ct.elements[6]*=l,Ct.elements[8]*=c,Ct.elements[9]*=c,Ct.elements[10]*=c,t.setFromRotationMatrix(Ct),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let u,p;if(s===oe)u=-(a+r)/(a-r),p=-2*a*r/(a-r);else{if(s!==le)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);u=-a/(a-r),p=-a*r/(a-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(a-r),d=(t+e)*l,u=(n+i)*c;let p,f;if(s===oe)p=(a+r)*h,f=-2*h;else{if(s!==le)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Rt=new Je,Ct=new At,Pt=new Je(0,0,0),Lt=new Je(1,1,1),Dt=new Je,It=new Je,Nt=new Je,Ot=new At,Ut=new Ke;class Ft{constructor(e=0,t=0,n=0,i=Ft.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],c=i[9],h=i[2],d=i[6],u=i[10];switch(t){case"XYZ":this._y=Math.asin(me(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-me(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(me(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-me(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(me(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(s,u));break;case"XZY":this._z=Math.asin(-me(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ot.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ot,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ut.setFromEuler(this),this.setFromQuaternion(Ut,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}}Ft.DEFAULT_ORDER="XYZ";class Bt{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){$t.subVectors(i,t),en.subVectors(n,t),tn.subVectors(e,t);const a=$t.dot($t),s=$t.dot(en),o=$t.dot(tn),l=en.dot(en),c=en.dot(tn),h=a*l-s*s;if(0===h)return r.set(-2,-1,-1);const d=1/h,u=(l*o-s*c)*d,p=(a*c-s*o)*d;return r.set(1-u-p,p,u)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,nn),nn.x>=0&&nn.y>=0&&nn.x+nn.y<=1}static getUV(e,t,n,i,r,a,s,o){return!1===hn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),hn=!0),this.getInterpolation(e,t,n,i,r,a,s,o)}static getInterpolation(e,t,n,i,r,a,s,o){return this.getBarycoord(e,t,n,i,nn),o.setScalar(0),o.addScaledVector(r,nn.x),o.addScaledVector(a,nn.y),o.addScaledVector(s,nn.z),o}static isFrontFacing(e,t,n,i){return $t.subVectors(n,t),en.subVectors(e,t),$t.cross(en).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return $t.subVectors(this.c,this.b),en.subVectors(this.a,this.b),.5*$t.cross(en).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return dn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return dn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===hn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),hn=!0),dn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return dn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return dn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,s;rn.subVectors(i,n),an.subVectors(r,n),on.subVectors(e,n);const o=rn.dot(on),l=an.dot(on);if(o<=0&&l<=0)return t.copy(n);ln.subVectors(e,i);const c=rn.dot(ln),h=an.dot(ln);if(c>=0&&h<=c)return t.copy(i);const d=o*h-c*l;if(d<=0&&o>=0&&c<=0)return a=o/(o-c),t.copy(n).addScaledVector(rn,a);cn.subVectors(e,r);const u=rn.dot(cn),p=an.dot(cn);if(p>=0&&u<=p)return t.copy(r);const f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return s=l/(l-p),t.copy(n).addScaledVector(an,s);const m=c*p-u*h;if(m<=0&&h-c>=0&&u-p>=0)return sn.subVectors(r,i),s=(h-c)/(h-c+(u-p)),t.copy(i).addScaledVector(sn,s);const g=1/(m+f+d);return a=f*g,s=d*g,t.copy(n).addScaledVector(rn,a).addScaledVector(an,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const un={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},pn={h:0,s:0,l:0},fn={h:0,s:0,l:0};function mn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class gn{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Z){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Oe.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Oe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Oe.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Oe.workingColorSpace){if(e=ge(e,1),t=me(t,0,1),n=me(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=mn(r,i,e+1/3),this.g=mn(r,i,e),this.b=mn(r,i,e-1/3)}return Oe.toWorkingColorSpace(this,i),this}setStyle(e,t=Z){function n(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 r;const a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[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=Z){const n=un[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ue(e.r),this.g=Ue(e.g),this.b=Ue(e.b),this}copyLinearToSRGB(e){return this.r=Fe(e.r),this.g=Fe(e.g),this.b=Fe(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Z){return Oe.fromWorkingColorSpace(vn.copy(this),e),65536*Math.round(me(255*vn.r,0,255))+256*Math.round(me(255*vn.g,0,255))+Math.round(me(255*vn.b,0,255))}getHexString(e=Z){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Oe.workingColorSpace){Oe.fromWorkingColorSpace(vn.copy(this),t);const n=vn.r,i=vn.g,r=vn.b,a=Math.max(n,i,r),s=Math.min(n,i,r);let o,l;const c=(s+a)/2;if(s===a)o=0,l=0;else{const e=a-s;switch(l=c<=.5?e/(a+s):e/(2-a-s),a){case n:o=(i-r)/e+(i0!=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 n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n: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 n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==s&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ie&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ie&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ie&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class yn extends xn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new gn(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=o,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 Sn=wn();function wn(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}const bn={toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=me(e,-65504,65504),Sn.floatView[0]=e;const t=Sn.uint32View[0],n=t>>23&511;return Sn.baseTable[n]+((8388607&t)>>Sn.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return Sn.uint32View[0]=Sn.mantissaTable[Sn.offsetTable[t]+(1023&e)]+Sn.exponentTable[t],Sn.floatView[0]}},Mn=new Je,Tn=new be;class En{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=re,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=L,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);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 n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}Bn.copy(r).invert(),zn.copy(e.ray).applyMatrix4(Bn),null!==n.boundingBox&&!1===zn.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,zn)}}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;rn.far?null:{distance:c,point:ei.clone(),object:e}}(e,t,n,i,Vn,Gn,Wn,$n);if(h){r&&(Yn.fromBufferAttribute(r,o),qn.fromBufferAttribute(r,l),Zn.fromBufferAttribute(r,c),h.uv=dn.getInterpolation($n,Vn,Gn,Wn,Yn,qn,Zn,new be)),a&&(Yn.fromBufferAttribute(a,o),qn.fromBufferAttribute(a,l),Zn.fromBufferAttribute(a,c),h.uv1=dn.getInterpolation($n,Vn,Gn,Wn,Yn,qn,Zn,new be),h.uv2=h.uv1),s&&(Kn.fromBufferAttribute(s,o),Jn.fromBufferAttribute(s,l),Qn.fromBufferAttribute(s,c),h.normal=dn.getInterpolation($n,Vn,Gn,Wn,Kn,Jn,Qn,new Je),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Je,materialIndex:0};dn.getNormal(Vn,Gn,Wn,e.normal),h.face=e}return h}class ii extends Fn{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const o=[],l=[],c=[],h=[];let d=0,u=0;function p(e,t,n,i,r,a,p,f,m,g,v){const _=a/m,x=p/g,y=a/2,S=p/2,w=f/2,b=m+1,M=g+1;let T=0,E=0;const A=new Je;for(let a=0;a0?1:-1,c.push(A.x,A.y,A.z),h.push(o/m),h.push(1-a/g),T+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class ci extends Qt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new At,this.projectionMatrix=new At,this.projectionMatrixInverse=new At,this.coordinateSystem=oe}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class hi extends ci{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=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*pe*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*ue*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*pe*Math.atan(Math.tan(.5*ue*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,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=n,this.view.offsetY=i,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*ue*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}const s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const di=-90;class ui extends Qt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new hi(di,1,e,t);i.layers=this.layers,this.add(i);const r=new hi(di,1,e,t);r.layers=this.layers,this.add(r);const a=new hi(di,1,e,t);a.layers=this.layers,this.add(a);const s=new hi(di,1,e,t);s.layers=this.layers,this.add(s);const o=new hi(di,1,e,t);o.layers=this.layers,this.add(o);const l=new hi(di,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(const e of t)this.remove(e);if(e===oe)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.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),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==le)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.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),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,s,o,l,c]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,c),e.setRenderTarget(h,d,u),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class pi extends We{constructor(e,t,n,i,r,a,s,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:v,n,i,r,a,s,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class fi extends Ye{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(Pe("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Y?Z:q),this.texture=new pi(i,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:E}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new ii(5,5,5),s=new li({name:"CubemapFromEquirect",uniforms:ri(n),vertexShader:i,fragmentShader:r,side:1,blending:0});s.uniforms.tEquirect.value=t;const o=new ti(a,s),l=t.minFilter;return t.minFilter===A&&(t.minFilter=E),new ui(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const mi=new Je,gi=new Je,vi=new Me;class _i{constructor(e=new Je(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=mi.subVectors(n,t).cross(gi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(mi),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||vi.getNormalMatrix(e),i=this.coplanarPoint(mi).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const xi=new _t,yi=new Je;class Si{constructor(e=new _i,t=new _i,n=new _i,i=new _i,r=new _i,a=new _i){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],c=i[5],h=i[6],d=i[7],u=i[8],p=i[9],f=i[10],m=i[11],g=i[12],v=i[13],_=i[14],x=i[15];if(n[0].setComponents(o-r,d-l,m-u,x-g).normalize(),n[1].setComponents(o+r,d+l,m+u,x+g).normalize(),n[2].setComponents(o+a,d+c,m+p,x+v).normalize(),n[3].setComponents(o-a,d-c,m-p,x-v).normalize(),n[4].setComponents(o-s,d-h,m-f,x-_).normalize(),t===oe)n[5].setComponents(o+s,d+h,m+f,x+_).normalize();else{if(t!==le)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,h,f,_).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),xi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),xi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xi)}intersectsSprite(e){return xi.center.set(0,0,0),xi.radius=.7071067811865476,xi.applyMatrix4(e.matrixWorld),this.intersectsSphere(xi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,yi.y=i.normal.y>0?e.max.y:e.min.y,yi.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(yi)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function wi(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function bi(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\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 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\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\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\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_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},Ei={common:{diffuse:{value:new gn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Me},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Me}},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 Me}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Me}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Me},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Me},normalScale:{value:new be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Me},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Me}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Me}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Me}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new gn(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 gn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0},uvTransform:{value:new Me}},sprite:{diffuse:{value:new gn(16777215)},opacity:{value:1},center:{value:new be(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Me},alphaMap:{value:null},alphaMapTransform:{value:new Me},alphaTest:{value:0}}},Ai={basic:{uniforms:ai([Ei.common,Ei.specularmap,Ei.envmap,Ei.aomap,Ei.lightmap,Ei.fog]),vertexShader:Ti.meshbasic_vert,fragmentShader:Ti.meshbasic_frag},lambert:{uniforms:ai([Ei.common,Ei.specularmap,Ei.envmap,Ei.aomap,Ei.lightmap,Ei.emissivemap,Ei.bumpmap,Ei.normalmap,Ei.displacementmap,Ei.fog,Ei.lights,{emissive:{value:new gn(0)}}]),vertexShader:Ti.meshlambert_vert,fragmentShader:Ti.meshlambert_frag},phong:{uniforms:ai([Ei.common,Ei.specularmap,Ei.envmap,Ei.aomap,Ei.lightmap,Ei.emissivemap,Ei.bumpmap,Ei.normalmap,Ei.displacementmap,Ei.fog,Ei.lights,{emissive:{value:new gn(0)},specular:{value:new gn(1118481)},shininess:{value:30}}]),vertexShader:Ti.meshphong_vert,fragmentShader:Ti.meshphong_frag},standard:{uniforms:ai([Ei.common,Ei.envmap,Ei.aomap,Ei.lightmap,Ei.emissivemap,Ei.bumpmap,Ei.normalmap,Ei.displacementmap,Ei.roughnessmap,Ei.metalnessmap,Ei.fog,Ei.lights,{emissive:{value:new gn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ti.meshphysical_vert,fragmentShader:Ti.meshphysical_frag},toon:{uniforms:ai([Ei.common,Ei.aomap,Ei.lightmap,Ei.emissivemap,Ei.bumpmap,Ei.normalmap,Ei.displacementmap,Ei.gradientmap,Ei.fog,Ei.lights,{emissive:{value:new gn(0)}}]),vertexShader:Ti.meshtoon_vert,fragmentShader:Ti.meshtoon_frag},matcap:{uniforms:ai([Ei.common,Ei.bumpmap,Ei.normalmap,Ei.displacementmap,Ei.fog,{matcap:{value:null}}]),vertexShader:Ti.meshmatcap_vert,fragmentShader:Ti.meshmatcap_frag},points:{uniforms:ai([Ei.points,Ei.fog]),vertexShader:Ti.points_vert,fragmentShader:Ti.points_frag},dashed:{uniforms:ai([Ei.common,Ei.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ti.linedashed_vert,fragmentShader:Ti.linedashed_frag},depth:{uniforms:ai([Ei.common,Ei.displacementmap]),vertexShader:Ti.depth_vert,fragmentShader:Ti.depth_frag},normal:{uniforms:ai([Ei.common,Ei.bumpmap,Ei.normalmap,Ei.displacementmap,{opacity:{value:1}}]),vertexShader:Ti.meshnormal_vert,fragmentShader:Ti.meshnormal_frag},sprite:{uniforms:ai([Ei.sprite,Ei.fog]),vertexShader:Ti.sprite_vert,fragmentShader:Ti.sprite_frag},background:{uniforms:{uvTransform:{value:new Me},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ti.background_vert,fragmentShader:Ti.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ti.backgroundCube_vert,fragmentShader:Ti.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ti.cube_vert,fragmentShader:Ti.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ti.equirect_vert,fragmentShader:Ti.equirect_frag},distanceRGBA:{uniforms:ai([Ei.common,Ei.displacementmap,{referencePosition:{value:new Je},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ti.distanceRGBA_vert,fragmentShader:Ti.distanceRGBA_frag},shadow:{uniforms:ai([Ei.lights,Ei.fog,{color:{value:new gn(0)},opacity:{value:1}}]),vertexShader:Ti.shadow_vert,fragmentShader:Ti.shadow_frag}};Ai.physical={uniforms:ai([Ai.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Me},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Me},clearcoatNormalScale:{value:new be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Me},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Me},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Me},sheen:{value:0},sheenColor:{value:new gn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Me},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Me},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Me},transmissionSamplerSize:{value:new be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Me},attenuationDistance:{value:0},attenuationColor:{value:new gn(0)},specularColor:{value:new gn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Me},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Me},anisotropyVector:{value:new be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Me}}]),vertexShader:Ti.meshphysical_vert,fragmentShader:Ti.meshphysical_frag};const Ri={r:0,b:0,g:0};function Ci(e,t,n,i,r,a,s){const o=new gn(0);let l,c,h=!0===a?0:1,d=null,u=0,p=null;function f(t,n){t.getRGB(Ri,si(e)),i.buffers.color.setClear(Ri.r,Ri.g,Ri.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,f(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,f(o,h)},render:function(a,m){let g=!1,v=!0===m.isScene?m.background:null;v&&v.isTexture&&(v=(m.backgroundBlurriness>0?n:t).get(v)),null===v?f(o,h):v&&v.isColor&&(f(v,1),g=!0);const _=e.xr.getEnvironmentBlendMode();"additive"===_?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===_&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===x)?(void 0===c&&(c=new ti(new ii(1,1,1),new li({name:"BackgroundCubeMaterial",uniforms:ri(Ai.backgroundCube.uniforms),vertexShader:Ai.backgroundCube.vertexShader,fragmentShader:Ai.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,c.material.toneMapped=Oe.getTransfer(v.colorSpace)!==ee,d===v&&u===v.version&&p===e.toneMapping||(c.material.needsUpdate=!0,d=v,u=v.version,p=e.toneMapping),c.layers.enableAll(),a.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(void 0===l&&(l=new ti(new Mi(2,2),new li({name:"BackgroundMaterial",uniforms:ri(Ai.background.uniforms),vertexShader:Ai.background.vertexShader,fragmentShader:Ai.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=Oe.getTransfer(v.colorSpace)!==ee,!0===v.matrixAutoUpdate&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),d===v&&u===v.version&&p===e.toneMapping||(l.material.needsUpdate=!0,d=v,u=v.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null))}}}function Pi(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),s=i.isWebGL2||null!==a,o={},l=p(null);let c=l,h=!1;function d(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function u(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e=0){const n=r[t];let i=a[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;s++}return c.attributesNum!==s||c.index!==i}(r,x,u,y),S&&function(e,t,n,i){const r={},a=t.attributes;let s=0;const o=n.getAttributes();for(const t in o)if(o[t].location>=0){let n=a[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,s++}c.attributes=r,c.attributesNum=s,c.index=i}(r,x,u,y)}else{const e=!0===l.wireframe;c.geometry===x.id&&c.program===u.id&&c.wireframe===e||(c.geometry=x.id,c.program=u.id,c.wireframe=e,S=!0)}null!==y&&n.update(y,e.ELEMENT_ARRAY_BUFFER),(S||h)&&(h=!1,function(r,a,s,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();const l=o.attributes,c=s.getAttributes(),h=a.defaultAttributeValues;for(const t in c){const a=c[t];if(a.location>=0){let s=l[t];if(void 0===s&&("instanceMatrix"===t&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){const t=s.normalized,l=s.itemSize,c=n.get(s);if(void 0===c)continue;const h=c.buffer,d=c.type,u=c.bytesPerElement,p=!0===i.isWebGL2&&(d===e.INT||d===e.UNSIGNED_INT||1013===s.gpuType);if(s.isInterleavedBufferAttribute){const n=s.data,i=n.stride,c=s.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&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 a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let s=void 0!==n.precision?n.precision:"highp";const o=r(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=a||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),_=d>0,x=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:u,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:x,floatVertexTextures:_&&x,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function Ii(e){const t=this;let n=null,i=0,r=!1,a=!1;const s=new _i,o=new Me,l={value:null,needsUpdate:!1};function c(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),t.numPlanes=i,t.numIntersection=0);else{const e=a?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(d,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=e}}}function Ni(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=v:304===t&&(e.mapping=_),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping;if(303===a||304===a){if(t.has(r))return n(t.get(r).texture,r.mapping);{const a=r.image;if(a&&a.height>0){const s=new fi(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class Oi extends ci{constructor(e=-1,t=1,n=1,i=-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=n,this.bottom=i,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,n,i,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=n,this.view.offsetY=i,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,s=i+t,o=i-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,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,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 Ui=[.125,.215,.35,.446,.526,.582],Fi=new Oi,Bi=new gn;let zi=null,ki=0,Hi=0;const Vi=(1+Math.sqrt(5))/2,Gi=1/Vi,Wi=[new Je(1,1,1),new Je(-1,1,1),new Je(1,1,-1),new Je(-1,1,-1),new Je(0,Vi,Gi),new Je(0,Vi,-Gi),new Je(Gi,0,Vi),new Je(-Gi,0,Vi),new Je(Vi,Gi,0),new Je(-Vi,Gi,0)];class ji{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){zi=this._renderer.getRenderTarget(),ki=this._renderer.getActiveCubeFace(),Hi=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Zi(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=qi(),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;ee-4?o=Ui[s-e+4-1]:0===s&&(o=0),i.push(o);const l=1/(a-2),c=-l,h=1+l,d=[c,c,h,c,h,h,c,c,h,h,c,h],u=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*u),_=new Float32Array(m*p*u),x=new Float32Array(g*p*u);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),_.set(d,m*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const y=new Fn;y.setAttribute("position",new En(v,f)),y.setAttribute("uv",new En(_,m)),y.setAttribute("faceIndex",new En(x,g)),t.push(y),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(20),r=new Je(0,1,0);return new li({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\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",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(i,e,t)}return i}_compileMaterial(e){const t=new ti(this._lodPlanes[0],e);this._renderer.compile(t,Fi)}_sceneToCubeUV(e,t,n,i){const r=new hi(90,1,t,n),a=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Bi),o.toneMapping=h,o.autoClear=!1;const d=new yn({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new ti(new ii,d);let p=!1;const f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,p=!0):(d.color.copy(Bi),p=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,a[t],0),r.lookAt(s[t],0,0)):1===n?(r.up.set(0,0,a[t]),r.lookAt(0,s[t],0)):(r.up.set(0,a[t],0),r.lookAt(0,0,s[t]));const l=this._cubeSize;Yi(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),p&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===v||e.mapping===_;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Zi()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=qi());const r=i?this._cubemapMaterial:this._equirectMaterial,a=new ti(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const s=this._cubeSize;Yi(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Fi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:ev-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(c,Fi)}}function Xi(e,t,n){const i=new Ye(e,t,n);return i.texture.mapping=x,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Yi(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function qi(){return new li({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\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",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Zi(){return new li({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\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",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 Ki(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===v||a===_;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new ji(e)),i=s?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const a=r.image;if(s&&a&&a.height>0||o&&a&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(a)){null===n&&(n=new ji(e));const a=s?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",i),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Ji(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Qi(e,t,n,i){const r={},a=new WeakMap;function s(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 n=o.morphAttributes[e];for(let e=0,i=n.length;et.maxTextureSize&&(T=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const E=new Float32Array(M*T*4*p),A=new qe(E,M,T,p);A.type=L,A.needsUpdate=!0;const R=4*b;for(let P=0;P0)return e;const r=t*n;let a=dr[r];if(void 0===a&&(a=new Float32Array(r),dr[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function vr(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function ma(e,t){const n=function(e){const t=Oe.getPrimaries(Oe.workingColorSpace),n=Oe.getPrimaries(e);let i;switch(t===n?i="":t===ne&&n===te?i="LinearDisplayP3ToLinearSRGB":t===te&&n===ne&&(i="LinearSRGBToLinearDisplayP3"),e){case K:case Q:return[i,"LinearTransferOETF"];case Z:case J:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),[i,"LinearTransferOETF"]}}(t);return`vec4 ${e}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function ga(e,t){let n;switch(t){case d:n="Linear";break;case u:n="Reinhard";break;case p:n="OptimizedCineon";break;case f:n="ACESFilmic";break;case m:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function va(e){return""!==e}function _a(e,t){const n=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,n).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 xa(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const ya=/^[ \t]*#include +<([\w\d./]+)>/gm;function Sa(e){return e.replace(ya,ba)}const wa=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function ba(e,t){let n=Ti[t];if(void 0===n){const e=wa.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Ti[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return Sa(n)}const Ma=/#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 Ta(e){return e.replace(Ma,Ea)}function Ea(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(E+="\n"),A=[b,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,M].filter(va).join("\n"),A.length>0&&(A+="\n")):(E=[Aa(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,M,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+y:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.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(va).join("\n"),A=[b,Aa(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,M,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+g:"",n.envMap?"#define "+y:"",n.envMap?"#define "+S:"",w?"#define CUBEUV_TEXEL_WIDTH "+w.texelWidth:"",w?"#define CUBEUV_TEXEL_HEIGHT "+w.texelHeight:"",w?"#define CUBEUV_MAX_MIP "+w.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==h?"#define TONE_MAPPING":"",n.toneMapping!==h?Ti.tonemapping_pars_fragment:"",n.toneMapping!==h?ga("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ti.colorspace_pars_fragment,ma("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(va).join("\n")),p=Sa(p),p=_a(p,n),p=xa(p,n),f=Sa(f),f=_a(f,n),f=xa(f,n),p=Ta(p),f=Ta(f),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(R="#version 300 es\n",E=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+E,A=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===ae?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===ae?"":"#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"+A);const C=R+E+p,P=R+A+f,L=da(d,d.VERTEX_SHADER,C),D=da(d,d.FRAGMENT_SHADER,P);function I(t){if(e.debug.checkShaderErrors){const n=d.getProgramInfoLog(T).trim(),i=d.getShaderInfoLog(L).trim(),r=d.getShaderInfoLog(D).trim();let a=!0,s=!0;if(!1===d.getProgramParameter(T,d.LINK_STATUS))if(a=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(d,T,L,D);else{const e=fa(d,L,"vertex"),t=fa(d,D,"fragment");console.error("THREE.WebGLProgram: Shader Error "+d.getError()+" - VALIDATE_STATUS "+d.getProgramParameter(T,d.VALIDATE_STATUS)+"\n\nProgram Info Log: "+n+"\n"+e+"\n"+t)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==r||(s=!1);s&&(t.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:E},fragmentShader:{log:r,prefix:A}})}d.deleteShader(L),d.deleteShader(D),N=new ha(d,T),O=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,q=a.clearcoat>0,Z=a.iridescence>0,J=a.sheen>0,Q=a.transmission>0,$=Y&&!!a.anisotropyMap,te=q&&!!a.clearcoatMap,ne=q&&!!a.clearcoatNormalMap,ie=q&&!!a.clearcoatRoughnessMap,re=Z&&!!a.iridescenceMap,ae=Z&&!!a.iridescenceThicknessMap,se=J&&!!a.sheenColorMap,oe=J&&!!a.sheenRoughnessMap,le=!!a.specularMap,ce=!!a.specularColorMap,he=!!a.specularIntensityMap,de=Q&&!!a.transmissionMap,ue=Q&&!!a.thicknessMap,pe=!!a.gradientMap,fe=!!a.alphaMap,me=a.alphaTest>0,ge=!!a.alphaHash,ve=!!a.extensions,_e=!!S.attributes.uv1,xe=!!S.attributes.uv2,ye=!!S.attributes.uv3;let Se=h;return a.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(Se=e.toneMapping)),{isWebGL2:d,shaderID:T,shaderType:a.type,shaderName:a.name,vertexShader:R,fragmentShader:C,defines:a.defines,customVertexShaderID:P,customFragmentShaderID:L,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:O,instancing:N,instancingColor:N&&null!==_.instanceColor,supportsVertexTextures:p,outputColorSpace:null===I?e.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:K,map:U,matcap:F,envMap:B,envMapMode:B&&b.mapping,envMapCubeUVHeight:M,aoMap:z,lightMap:k,bumpMap:H,normalMap:V,displacementMap:p&&G,emissiveMap:W,normalMapObjectSpace:V&&1===a.normalMapType,normalMapTangentSpace:V&&0===a.normalMapType,metalnessMap:j,roughnessMap:X,anisotropy:Y,anisotropyMap:$,clearcoat:q,clearcoatMap:te,clearcoatNormalMap:ne,clearcoatRoughnessMap:ie,iridescence:Z,iridescenceMap:re,iridescenceThicknessMap:ae,sheen:J,sheenColorMap:se,sheenRoughnessMap:oe,specularMap:le,specularColorMap:ce,specularIntensityMap:he,transmission:Q,transmissionMap:de,thicknessMap:ue,gradientMap:pe,opaque:!1===a.transparent&&1===a.blending,alphaMap:fe,alphaTest:me,alphaHash:ge,combine:a.combine,mapUv:U&&g(a.map.channel),aoMapUv:z&&g(a.aoMap.channel),lightMapUv:k&&g(a.lightMap.channel),bumpMapUv:H&&g(a.bumpMap.channel),normalMapUv:V&&g(a.normalMap.channel),displacementMapUv:G&&g(a.displacementMap.channel),emissiveMapUv:W&&g(a.emissiveMap.channel),metalnessMapUv:j&&g(a.metalnessMap.channel),roughnessMapUv:X&&g(a.roughnessMap.channel),anisotropyMapUv:$&&g(a.anisotropyMap.channel),clearcoatMapUv:te&&g(a.clearcoatMap.channel),clearcoatNormalMapUv:ne&&g(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&g(a.clearcoatRoughnessMap.channel),iridescenceMapUv:re&&g(a.iridescenceMap.channel),iridescenceThicknessMapUv:ae&&g(a.iridescenceThicknessMap.channel),sheenColorMapUv:se&&g(a.sheenColorMap.channel),sheenRoughnessMapUv:oe&&g(a.sheenRoughnessMap.channel),specularMapUv:le&&g(a.specularMap.channel),specularColorMapUv:ce&&g(a.specularColorMap.channel),specularIntensityMapUv:he&&g(a.specularIntensityMap.channel),transmissionMapUv:de&&g(a.transmissionMap.channel),thicknessMapUv:ue&&g(a.thicknessMap.channel),alphaMapUv:fe&&g(a.alphaMap.channel),vertexTangents:!!S.attributes.tangent&&(V||Y),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!S.attributes.color&&4===S.attributes.color.itemSize,vertexUv1s:_e,vertexUv2s:xe,vertexUv3s:ye,pointsUvs:!0===_.isPoints&&!!S.attributes.uv&&(U||fe),fog:!!y,useFog:!0===a.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==S.morphAttributes.position,morphNormals:void 0!==S.morphAttributes.normal,morphColors:void 0!==S.morphAttributes.color,morphTargetsCount:A,morphTextureStride:D,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:Se,useLegacyLights:e._useLegacyLights,decodeVideoTexture:U&&!0===a.map.isVideoTexture&&Oe.getTransfer(a.map.colorSpace)===ee,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:ve&&!0===a.extensions.derivatives,extensionFragDepth:ve&&!0===a.extensions.fragDepth,extensionDrawBuffers:ve&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:ve&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:d||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(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.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0),t.supportsVertexTextures&&o.enable(1),t.instancing&&o.enable(2),t.instancingColor&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),t.alphaHash&&o.enable(18),t.batching&&o.enable(19),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.skinning&&o.enable(4),t.morphTargets&&o.enable(5),t.morphNormals&&o.enable(6),t.morphColors&&o.enable(7),t.premultipliedAlpha&&o.enable(8),t.shadowMapEnabled&&o.enable(9),t.useLegacyLights&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=m[e.type];let n;if(t){const e=Ai[t];n=oi.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e0?i.push(h):!0===s.transparent?r.push(h):n.push(h)},unshift:function(e,t,s,o,l,c){const h=a(e,t,s,o,l,c);s.transmission>0?i.unshift(h):!0===s.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||Na),i.length>1&&i.sort(t||Oa),r.length>1&&r.sort(t||Oa)}}}function Fa(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new Ua,e.set(t,[r])):n>=i.length?(r=new Ua,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function Ba(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Je,color:new gn};break;case"SpotLight":n={position:new Je,direction:new Je,color:new gn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Je,color:new gn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Je,skyColor:new gn,groundColor:new gn};break;case"RectAreaLight":n={color:new gn,position:new Je,halfWidth:new Je,halfHeight:new Je}}return e[t.id]=n,n}}}let za=0;function ka(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Ha(e,t){const n=new Ba,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new Je);const a=new Je,s=new At,o=new At;return{setup:function(a,s){let o=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let h=0,d=0,u=0,p=0,f=0,m=0,g=0,v=0,_=0,x=0,y=0;a.sort(ka);const S=!0===s?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Ei.LTC_FLOAT_1,r.rectAreaLTC2=Ei.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Ei.LTC_HALF_1,r.rectAreaLTC2=Ei.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const w=r.hash;w.directionalLength===h&&w.pointLength===d&&w.spotLength===u&&w.rectAreaLength===p&&w.hemiLength===f&&w.numDirectionalShadows===m&&w.numPointShadows===g&&w.numSpotShadows===v&&w.numSpotMaps===_&&w.numLightProbes===y||(r.directional.length=h,r.spot.length=u,r.rectArea.length=p,r.point.length=d,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+_-x,r.spotLightMap.length=_,r.numSpotLightShadowsWithMaps=x,r.numLightProbes=y,w.directionalLength=h,w.pointLength=d,w.spotLength=u,w.rectAreaLength=p,w.hemiLength=f,w.numDirectionalShadows=m,w.numPointShadows=g,w.numSpotShadows=v,w.numSpotMaps=_,w.numLightProbes=y,r.version=za++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const d=t.matrixWorldInverse;for(let t=0,u=e.length;t=a.length?(s=new Va(e,t),a.push(s)):s=a[r],s},dispose:function(){n=new WeakMap}}}class Wa extends xn{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 ja extends xn{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 Xa(e,t,n){let r=new Si;const s=new be,o=new be,l=new je,c=new Wa({depthPacking:3201}),h=new ja,d={},u=n.maxTextureSize,p={0:1,1:0,2:2},f=new li({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new be},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const g=new Fn;g.setAttribute("position",new En(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new ti(g,f),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=i;let x=this.type;function y(n,i){const r=t.update(v);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,m.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,m.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ye(s.x,s.y)),f.uniforms.shadow_pass.value=n.map.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,f,v,null),m.uniforms.shadow_pass.value=n.mapPass.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,m,v,null)}function S(t,n,i,r){let s=null;const o=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)s=o;else if(s=!0===i.isPointLight?h:c,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let i=d[e];void 0===i&&(i={},d[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===a?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:p[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(e.properties.get(s).light=i),s}function w(n,i,s,o,l){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&l===a)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const r=t.update(n),a=n.material;if(Array.isArray(a)){const t=r.groups;for(let c=0,h=t.length;cu||s.y>u)&&(s.x>u&&(o.x=Math.floor(u/g.x),s.x=o.x*g.x,d.mapSize.x=o.x),s.y>u&&(o.y=Math.floor(u/g.y),s.y=o.y*g.y,d.mapSize.y=o.y)),null===d.map||!0===f||!0===m){const e=this.type!==a?{minFilter:b,magFilter:b}:{};null!==d.map&&d.map.dispose(),d.map=new Ye(s.x,s.y,e),d.map.texture.name=h.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const v=d.getViewportCount();for(let e=0;e=1):-1!==N.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(N)[1]),D=I>=2);let O=null,U={};const F=e.getParameter(e.SCISSOR_BOX),B=e.getParameter(e.VIEWPORT),z=(new je).fromArray(F),k=(new je).fromArray(B);function H(t,n,r,a){const s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;oi||e.height>i)&&(r=i/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 i=t?xe:Math.floor,a=i(r*e.width),s=i(r*e.height);void 0===m&&(m=_(a,s));const o=n?_(a,s):m;return o.width=a,o.height=s,o.getContext("2d").drawImage(e,0,0,a,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+s+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function F(e){return _e(e.width)&&_e(e.height)}function B(e,t){return e.generateMipmaps&&t&&e.minFilter!==b&&e.minFilter!==E}function z(t){e.generateMipmap(t)}function k(n,i,r,a,s=!1){if(!1===o)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;if(i===e.RED&&(r===e.FLOAT&&(l=e.R32F),r===e.HALF_FLOAT&&(l=e.R16F),r===e.UNSIGNED_BYTE&&(l=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(l=e.R8UI),r===e.UNSIGNED_SHORT&&(l=e.R16UI),r===e.UNSIGNED_INT&&(l=e.R32UI),r===e.BYTE&&(l=e.R8I),r===e.SHORT&&(l=e.R16I),r===e.INT&&(l=e.R32I)),i===e.RG&&(r===e.FLOAT&&(l=e.RG32F),r===e.HALF_FLOAT&&(l=e.RG16F),r===e.UNSIGNED_BYTE&&(l=e.RG8)),i===e.RGBA){const t=s?$:Oe.getTransfer(a);r===e.FLOAT&&(l=e.RGBA32F),r===e.HALF_FLOAT&&(l=e.RGBA16F),r===e.UNSIGNED_BYTE&&(l=t===ee?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function H(e,t,n){return!0===B(e,n)||e.isFramebufferTexture&&e.minFilter!==b&&e.minFilter!==E?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 V(t){return t===b||t===M||t===T?e.NEAREST:e.LINEAR}function G(e){const t=e.target;t.removeEventListener("dispose",G),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&j(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&f.delete(t)}function W(t){const n=t.target;n.removeEventListener("dispose",W),function(t){const n=t.texture,r=i.get(t),a=i.get(n);if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(r.__webglFramebuffer[t]))for(let n=0;n0&&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 ie(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}const Z={[y]:e.REPEAT,[S]:e.CLAMP_TO_EDGE,[w]:e.MIRRORED_REPEAT},J={[b]:e.NEAREST,[M]:e.NEAREST_MIPMAP_NEAREST,[T]:e.NEAREST_MIPMAP_LINEAR,[E]:e.LINEAR,1007:e.LINEAR_MIPMAP_NEAREST,[A]:e.LINEAR_MIPMAP_LINEAR},Q={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function te(n,a,s){if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,Z[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,Z[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,Z[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,J[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,J[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),a.wrapS===S&&a.wrapT===S||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,V(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,V(a.minFilter)),a.minFilter!==b&&a.minFilter!==E&&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(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,Q[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===b)return;if(a.minFilter!==T&&a.minFilter!==A)return;if(a.type===L&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&a.type===D&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function ne(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",G));const r=n.source;let a=g.get(r);void 0===a&&(a={},g.set(r,a));const o=function(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()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&j(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function ie(t,r,s){let l=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(l=e.TEXTURE_3D);const c=ne(t,r),d=r.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+s);const u=i.get(d);if(d.version!==u.__version||!0===c){n.activeTexture(e.TEXTURE0+s);const t=Oe.getPrimaries(Oe.workingColorSpace),i=r.colorSpace===q?null:Oe.getPrimaries(r.colorSpace),p=r.colorSpace===q||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;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,p);const f=function(e){return!o&&(e.wrapS!==S||e.wrapT!==S||e.minFilter!==b&&e.minFilter!==E)}(r)&&!1===F(r.image);let m=x(r.image,f,!1,h);m=he(r,m);const g=F(m)||o,v=a.convert(r.format,r.colorSpace);let _,y=a.convert(r.type),w=k(r.internalFormat,v,y,r.colorSpace,r.isVideoTexture);te(l,r,g);const M=r.mipmaps,T=o&&!0!==r.isVideoTexture&&36196!==w,A=void 0===u.__version||!0===c,R=H(r,m,g);if(r.isDepthTexture)w=e.DEPTH_COMPONENT,o?w=r.type===L?e.DEPTH_COMPONENT32F:r.type===P?e.DEPTH_COMPONENT24:r.type===I?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===L&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===O&&w===e.DEPTH_COMPONENT&&r.type!==C&&r.type!==P&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=P,y=a.convert(r.type)),r.format===U&&w===e.DEPTH_COMPONENT&&(w=e.DEPTH_STENCIL,r.type!==I&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=I,y=a.convert(r.type))),A&&(T?n.texStorage2D(e.TEXTURE_2D,1,w,m.width,m.height):n.texImage2D(e.TEXTURE_2D,0,w,m.width,m.height,0,v,y,null));else if(r.isDataTexture)if(M.length>0&&g){T&&A&&n.texStorage2D(e.TEXTURE_2D,R,w,M[0].width,M[0].height);for(let t=0,i=M.length;t>=1,i>>=1}}else if(M.length>0&&g){T&&A&&n.texStorage2D(e.TEXTURE_2D,R,w,M[0].width,M[0].height);for(let t=0,i=M.length;t>c),i=Math.max(1,r.height>>c);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,c,p,t,i,r.depth,0,h,d,null):n.texImage2D(l,c,p,t,i,0,h,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),ce(r)?u.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,0,le(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ae(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=!0===o?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(i||ce(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===L?r=e.DEPTH_COMPONENT32F:t.type===P&&(r=e.DEPTH_COMPONENT24));const i=le(n);ce(n)?u.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=le(n);i&&!1===ce(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):ce(n)?u.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function he(e,n){const i=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===se||i!==K&&i!==q&&(Oe.getTransfer(i)===ee?!1===o?!0===t.has("EXT_sRGB")&&r===N?(e.format=se,e.minFilter=E,e.generateMipmaps=!1):n=ze.sRGBToLinear(n):r===N&&a===R||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const e=X;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),X+=1,e},this.resetTextureUnits=function(){X=0},this.setTexture2D=Y,this.setTexture2DArray=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?ie(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?ie(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?function(t,r,s){if(6!==r.image.length)return;const l=ne(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);const d=i.get(h);if(h.version!==d.__version||!0===l){n.activeTexture(e.TEXTURE0+s);const t=Oe.getPrimaries(Oe.workingColorSpace),i=r.colorSpace===q?null:Oe.getPrimaries(r.colorSpace),u=r.colorSpace===q||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;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,u);const p=r.isCompressedTexture||r.image[0].isCompressedTexture,f=r.image[0]&&r.image[0].isDataTexture,m=[];for(let e=0;e<6;e++)m[e]=p||f?f?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),m[e]=he(r,m[e]);const g=m[0],v=F(g)||o,_=a.convert(r.format,r.colorSpace),y=a.convert(r.type),S=k(r.internalFormat,_,y,r.colorSpace),w=o&&!0!==r.isVideoTexture,b=void 0===d.__version||!0===l;let M,T=H(r,g,v);if(te(e.TEXTURE_CUBE_MAP,r,v),p){w&&b&&n.texStorage2D(e.TEXTURE_CUBE_MAP,T,S,g.width,g.height);for(let t=0;t<6;t++){M=m[t].mipmaps;for(let i=0;i0&&T++,n.texStorage2D(e.TEXTURE_CUBE_MAP,T,S,m[0].width,m[0].height));for(let t=0;t<6;t++)if(f){w?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,_,y,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,S,m[t].width,m[t].height,0,_,y,m[t].data);for(let i=0;i0){c.__webglFramebuffer[t]=[];for(let n=0;n0){c.__webglFramebuffer=[];for(let t=0;t0&&!1===ce(t)){const i=u?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0&&!1===ce(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;const l=[],c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(Qa)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Ja;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class es extends ce{constructor(e,t){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,c=null,h=null,d=null,u=null,p=null;const f=t.getContextAttributes();let m=null,g=null;const v=[],_=[],x=new be;let y=null;const S=new hi;S.layers.enable(1),S.viewport=new je;const w=new hi;w.layers.enable(2),w.viewport=new je;const b=[S,w],M=new Ka;M.layers.enable(1),M.layers.enable(2);let T=null,E=null;function A(e){const t=_.indexOf(e.inputSource);if(-1===t)return;const n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function C(){i.removeEventListener("select",A),i.removeEventListener("selectstart",A),i.removeEventListener("selectend",A),i.removeEventListener("squeeze",A),i.removeEventListener("squeezestart",A),i.removeEventListener("squeezeend",A),i.removeEventListener("end",C),i.removeEventListener("inputsourceschange",L);for(let e=0;e=0&&(_[i]=null,v[i].disconnect(n))}for(let t=0;t=_.length){_.push(n),i=e;break}if(null===_[e]){_[e]=n,i=e;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new $a,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new $a,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new $a,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",A),i.addEventListener("selectstart",A),i.addEventListener("selectend",A),i.addEventListener("squeeze",A),i.addEventListener("squeezestart",A),i.addEventListener("squeezeend",A),i.addEventListener("end",C),i.addEventListener("inputsourceschange",L),!0!==f.xrCompatible&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(x),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),g=new Ye(u.framebufferWidth,u.framebufferHeight,{format:N,type:R,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,a=null,s=null;f.depth&&(s=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?U:O,a=f.stencil?I:P);const o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(o),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),g=new Ye(d.textureWidth,d.textureHeight,{format:N,type:R,depthTexture:new ar(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),k.setContext(i),k.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const D=new Je,F=new Je;function B(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===i)return;M.near=w.near=S.near=e.near,M.far=w.far=S.far=e.far,T===M.near&&E===M.far||(i.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,E=M.far);const t=e.parent,n=M.cameras;B(M,t);for(let e=0;e0&&(i.alphaTest.value=r.alphaTest);const a=t.get(r).envMap;if(a&&(i.envMap.value=a,i.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const t=!0===e._useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,si(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform)),e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform));t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(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,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(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,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(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,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(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,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(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,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function ns(e,t,n,i){let r={},a={},s=[];const o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){const i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{const e=Array.isArray(i)?i:[i],r=[];for(let t=0;t0&&(i=n%16,0!==i&&16-i-a.boundary<0&&(n+=16-i,r.__offset=n)),n+=a.storage}i=n%16,i>0&&(n+=16-i),e.__size=n,e.__cache={}}(n),u=function(t){const n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,f=!!n.morphAttributes.color;let m=h;i.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(m=y.toneMapping));const g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=void 0!==g?g.length:0,x=ce.get(i),S=v.state.lights;if(!0===J&&(!0===Q||e!==E)){const t=e===E&&i.id===T;Se.setState(i,e,t)}let w=!1;i.version===x.__version?x.needsLights&&x.lightsStateVersion!==S.state.version||x.outputColorSpace!==o||r.isBatchedMesh&&!1===x.batching?w=!0:r.isBatchedMesh||!0!==x.batching?r.isInstancedMesh&&!1===x.instancing?w=!0:r.isInstancedMesh||!0!==x.instancing?r.isSkinnedMesh&&!1===x.skinning?w=!0:r.isSkinnedMesh||!0!==x.skinning?r.isInstancedMesh&&!0===x.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===x.instancingColor&&null!==r.instanceColor||x.envMap!==l||!0===i.fog&&x.fog!==a?w=!0:void 0===x.numClippingPlanes||x.numClippingPlanes===Se.numPlanes&&x.numIntersection===Se.numIntersection?(x.vertexAlphas!==c||x.vertexTangents!==d||x.morphTargets!==u||x.morphNormals!==p||x.morphColors!==f||x.toneMapping!==m||!0===se.isWebGL2&&x.morphTargetsCount!==_)&&(w=!0):w=!0:w=!0:w=!0:w=!0:(w=!0,x.__version=i.version);let b=x.currentProgram;!0===w&&(b=Qe(i,t,r));let A=!1,R=!1,C=!1;const P=b.getUniforms(),L=x.uniforms;if(oe.useProgram(b.program)&&(A=!0,R=!0,C=!0),i.id!==T&&(T=i.id,R=!0),A||E!==e){P.setValue(De,"projectionMatrix",e.projectionMatrix),P.setValue(De,"viewMatrix",e.matrixWorldInverse);const t=P.map.cameraPosition;void 0!==t&&t.setValue(De,ne.setFromMatrixPosition(e.matrixWorld)),se.logarithmicDepthBuffer&&P.setValue(De,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(De,"isOrthographic",!0===e.isOrthographicCamera),E!==e&&(E=e,R=!0,C=!0)}if(r.isSkinnedMesh){P.setOptional(De,r,"bindMatrix"),P.setOptional(De,r,"bindMatrixInverse");const e=r.skeleton;e&&(se.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(De,"boneTexture",e.boneTexture,he)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}r.isBatchedMesh&&(P.setOptional(De,r,"batchingTexture"),P.setValue(De,"batchingTexture",r._matricesTexture,he));const D=n.morphAttributes;var I,N;if((void 0!==D.position||void 0!==D.normal||void 0!==D.color&&!0===se.isWebGL2)&&Te.update(r,n,b),(R||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(De,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(L.envMap.value=l,L.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),R&&(P.setValue(De,"toneMappingExposure",y.toneMappingExposure),x.needsLights&&(N=C,(I=L).ambientLightColor.needsUpdate=N,I.lightProbe.needsUpdate=N,I.directionalLights.needsUpdate=N,I.directionalLightShadows.needsUpdate=N,I.pointLights.needsUpdate=N,I.pointLightShadows.needsUpdate=N,I.spotLights.needsUpdate=N,I.spotLightShadows.needsUpdate=N,I.rectAreaLights.needsUpdate=N,I.hemisphereLights.needsUpdate=N),a&&!0===i.fog&&ve.refreshFogUniforms(L,a),ve.refreshMaterialUniforms(L,i,V,H,$),ha.upload(De,$e(x),L,he)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ha.upload(De,$e(x),L,he),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&P.setValue(De,"center",r.center),P.setValue(De,"modelViewMatrix",r.modelViewMatrix),P.setValue(De,"normalMatrix",r.normalMatrix),P.setValue(De,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t{function n(){i.forEach((function(e){ce.get(e).currentProgram.isReady()&&i.delete(e)})),0!==i.size?setTimeout(n,10):t(e)}null!==ae.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let He=null;function Ve(){We.stop()}function Ge(){We.start()}const We=new wi;function Xe(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=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||q.intersectsSprite(e)){i&&ne.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ee);const t=me.update(e),r=e.material;r.visible&&g.push(e,t,r,n,ne.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||q.intersectsObject(e))){const t=me.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),ne.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),ne.copy(t.boundingSphere.center)),ne.applyMatrix4(e.matrixWorld).applyMatrix4(ee)),Array.isArray(r)){const i=t.groups;for(let a=0,s=i.length;a0&&function(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;const r=se.isWebGL2;null===$&&($=new Ye(1,1,{generateMipmaps:!0,type:ae.has("EXT_color_buffer_half_float")?D:R,minFilter:A,samples:r?4:0})),y.getDrawingBufferSize(te),r?$.setSize(te.x,te.y):$.setSize(xe(te.x),xe(te.y));const a=y.getRenderTarget();y.setRenderTarget($),y.getClearColor(B),z=y.getClearAlpha(),z<1&&y.setClearColor(16777215,.5),y.clear();const s=y.toneMapping;y.toneMapping=h,Ze(e,n,i),he.updateMultisampleRenderTarget($),he.updateRenderTargetMipmap($);let o=!1;for(let e=0,r=t.length;e0&&Ze(r,t,n),a.length>0&&Ze(a,t,n),s.length>0&&Ze(s,t,n),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function Ze(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r0?x[x.length-1]:null,_.pop(),g=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(e,t,n){ce.get(e.texture).__webglTexture=t,ce.get(e.depthTexture).__webglTexture=n;const i=ce.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===ae.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=ce.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){M=e,w=t,b=n;let i=!0,r=null,a=!1,s=!1;if(e){const o=ce.get(e);void 0!==o.__useDefaultFramebuffer?(oe.bindFramebuffer(De.FRAMEBUFFER,null),i=!1):void 0===o.__webglFramebuffer?he.setupRenderTarget(e):o.__hasExternalTextures&&he.rebindTextures(e,ce.get(e.texture).__webglTexture,ce.get(e.depthTexture).__webglTexture);const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=ce.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=se.isWebGL2&&e.samples>0&&!1===he.useMultisampledRTT(e)?ce.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,O.copy(e.viewport),U.copy(e.scissor),F=e.scissorTest}else O.copy(j).multiplyScalar(V).floor(),U.copy(X).multiplyScalar(V).floor(),F=Y;if(oe.bindFramebuffer(De.FRAMEBUFFER,r)&&se.drawBuffers&&i&&oe.drawBuffers(e,r),oe.viewport(O),oe.scissor(U),oe.setScissorTest(F),a){const i=ce.get(e.texture);De.framebufferTexture2D(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,De.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=ce.get(e.texture),r=t||0;De.framebufferTextureLayer(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}T=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ce.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){oe.bindFramebuffer(De.FRAMEBUFFER,o);try{const s=e.texture,o=s.format,l=s.type;if(o!==N&&Ce.convert(o)!==De.getParameter(De.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===D&&(ae.has("EXT_color_buffer_half_float")||se.isWebGL2&&ae.has("EXT_color_buffer_float"));if(!(l===R||Ce.convert(l)===De.getParameter(De.IMPLEMENTATION_COLOR_READ_TYPE)||l===L&&(se.isWebGL2||ae.has("OES_texture_float")||ae.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&De.readPixels(t,n,i,r,Ce.convert(o),Ce.convert(l),a)}finally{const e=null!==M?ce.get(M).__webglFramebuffer:null;oe.bindFramebuffer(De.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);he.setTexture2D(t,0),De.copyTexSubImage2D(De.TEXTURE_2D,n,0,0,e.x,e.y,r,a),oe.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,a=t.image.height,s=Ce.convert(n.format),o=Ce.convert(n.type);he.setTexture2D(n,0),De.pixelStorei(De.UNPACK_FLIP_Y_WEBGL,n.flipY),De.pixelStorei(De.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),De.pixelStorei(De.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?De.texSubImage2D(De.TEXTURE_2D,i,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?De.compressedTexSubImage2D(De.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):De.texSubImage2D(De.TEXTURE_2D,i,e.x,e.y,s,o,t.image),0===i&&n.generateMipmaps&&De.generateMipmap(De.TEXTURE_2D),oe.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(y.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=Ce.convert(i.format),c=Ce.convert(i.type);let h;if(i.isData3DTexture)he.setTexture3D(i,0),h=De.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");he.setTexture2DArray(i,0),h=De.TEXTURE_2D_ARRAY}De.pixelStorei(De.UNPACK_FLIP_Y_WEBGL,i.flipY),De.pixelStorei(De.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),De.pixelStorei(De.UNPACK_ALIGNMENT,i.unpackAlignment);const d=De.getParameter(De.UNPACK_ROW_LENGTH),u=De.getParameter(De.UNPACK_IMAGE_HEIGHT),p=De.getParameter(De.UNPACK_SKIP_PIXELS),f=De.getParameter(De.UNPACK_SKIP_ROWS),m=De.getParameter(De.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;De.pixelStorei(De.UNPACK_ROW_LENGTH,g.width),De.pixelStorei(De.UNPACK_IMAGE_HEIGHT,g.height),De.pixelStorei(De.UNPACK_SKIP_PIXELS,e.min.x),De.pixelStorei(De.UNPACK_SKIP_ROWS,e.min.y),De.pixelStorei(De.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?De.texSubImage3D(h,r,t.x,t.y,t.z,a,s,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),De.compressedTexSubImage3D(h,r,t.x,t.y,t.z,a,s,o,l,g.data)):De.texSubImage3D(h,r,t.x,t.y,t.z,a,s,o,l,c,g),De.pixelStorei(De.UNPACK_ROW_LENGTH,d),De.pixelStorei(De.UNPACK_IMAGE_HEIGHT,u),De.pixelStorei(De.UNPACK_SKIP_PIXELS,p),De.pixelStorei(De.UNPACK_SKIP_ROWS,f),De.pixelStorei(De.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&De.generateMipmap(h),oe.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?he.setTextureCube(e,0):e.isData3DTexture?he.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?he.setTexture2DArray(e,0):he.setTexture2D(e,0),oe.unbindTexture()},this.resetState=function(){w=0,b=0,M=null,oe.reset(),Pe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return oe}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===J?"display-p3":"srgb",t.unpackColorSpace=Oe.workingColorSpace===Q?"display-p3":"srgb"}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===Z?Y:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Y?Z:K}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}(class extends is{}).prototype.isWebGL1Renderer=!0;class rs extends Qt{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 as{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=re,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=fe()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;io)continue;d.applyMatrix4(this.matrixWorld);const a=e.ray.origin.distanceTo(d);ae.far||t.push({distance:a,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,a.start),i=Math.min(f.count,a.start+a.count)-1;no)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);ie.far||t.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:s})}}class Ks{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let a;a=t||e*n[r-1];let s,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),s=n[i]-a,s<0)o=i+1;else{if(!(s>0)){l=i;break}l=i-1}if(i=l,n[i]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),s=this.getPoint(r),o=t||(a.isVector2?new be:new Je);return o.copy(s).sub(a).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Je,i=[],r=[],a=[],s=new Je,o=new At;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Je)}r[0]=new Je,a[0]=new Je;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(i[t-1],i[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(me(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(s,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(me(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Js extends Ks{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t){const n=t||new be,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=i[(l-1)%r]:($s.subVectors(i[0],i[1]).add(i[0]),s=$s);const h=i[l%r],d=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(ro(s,o.x,l.x,c.x,h.x),ro(s,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Cn(h,3)),this.setAttribute("normal",new Cn(d,3)),this.setAttribute("uv",new Cn(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ho(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class uo extends Fn{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e,t,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const s=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)a[i][e]=0===e&&i===r?s:s.clone().lerp(o,e/l)}for(let e=0;e.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Cn(r,3)),this.setAttribute("normal",new Cn(r.slice(),3)),this.setAttribute("uv",new Cn(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uo(e.vertices,e.indices,e.radius,e.details)}}class po extends uo{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new po(e.radius,e.detail)}}class fo extends uo{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fo(e.radius,e.detail)}}class mo extends Fn{constructor(e=.5,t=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);const s=[],o=[],l=[],c=[];let h=e;const d=(t-e)/(i=Math.max(1,i)),u=new Je,p=new be;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=r+e/n*a;u.x=h*Math.cos(i),u.y=h*Math.sin(i),o.push(u.x,u.y,u.z),l.push(0,0,1),p.x=(u.x/t+1)/2,p.y=(u.y/t+1)/2,c.push(p.x,p.y)}h+=d}for(let e=0;e0)&&u.push(t,r,l),(e!==n-1||o0!=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}}class wo extends xn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new gn(16777215),this.specular=new gn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new gn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=o,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class bo extends xn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Mo extends xn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new gn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new gn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=o,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function To(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Eo(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Ao(e,t,n){const i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){const i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function Ro(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(t.push(a.time),n.push.apply(n,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(t.push(a.time),n.push(s)),a=e[r++]}while(void 0!==a)}class Co{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e=r)break e;{const s=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const e=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(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 n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&(s=i,ArrayBuffer.isView(s)&&!(s instanceof DataView)))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}var s;return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===X,r=e.length-1;let a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Io.prototype.TimeBufferType=Float32Array,Io.prototype.ValueBufferType=Float32Array,Io.prototype.DefaultInterpolation=j;class No extends Io{}No.prototype.ValueTypeName="bool",No.prototype.ValueBufferType=Array,No.prototype.DefaultInterpolation=W,No.prototype.InterpolantFactoryMethodLinear=void 0,No.prototype.InterpolantFactoryMethodSmooth=void 0;class Oo extends Io{}Oo.prototype.ValueTypeName="color";class Uo extends Io{}Uo.prototype.ValueTypeName="number";class Fo extends Co{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t);let l=e*s;for(let e=l+s;l!==e;l+=4)Ke.slerpFlat(r,0,a,l-s,a,l,o);return r}}class Bo extends Io{InterpolantFactoryMethodLinear(e){return new Fo(this.times,this.values,this.getValueSize(),e)}}Bo.prototype.ValueTypeName="quaternion",Bo.prototype.DefaultInterpolation=j,Bo.prototype.InterpolantFactoryMethodSmooth=void 0;class zo extends Io{}zo.prototype.ValueTypeName="string",zo.prototype.ValueBufferType=Array,zo.prototype.DefaultInterpolation=W,zo.prototype.InterpolantFactoryMethodLinear=void 0,zo.prototype.InterpolantFactoryMethodSmooth=void 0;class ko extends Io{}ko.prototype.ValueTypeName="vector";class Ho{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=fe(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(Vo(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(Io.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let e=0;e1){const e=a[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const a=[];for(const e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],s=[];Ro(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Yo[e])return void Yo[e].push({onLoad:t,onProgress:n,onError:i});Yo[e]=[],Yo[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=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 n=Yo[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),a=r?parseInt(r):0,s=0!==a;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{Go.add(e,t);const n=Yo[e];delete Yo[e];for(let e=0,i=n.length;e{const n=Yo[e];if(void 0===n)throw this.manager.itemError(e),t;delete Yo[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Ko extends Xo{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Go.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const s=Ae("img");function o(){c(),Go.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(e),s.src=e,s}}class Jo extends Xo{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new xs,s=new Zo(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,(function(e){let n;try{n=r.parse(e)}catch(e){if(void 0===i)return void console.error(e);i(e)}void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:S,a.wrapT=void 0!==n.wrapT?n.wrapT:S,a.magFilter=void 0!==n.magFilter?n.magFilter:E,a.minFilter=void 0!==n.minFilter?n.minFilter:E,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace?a.colorSpace=n.colorSpace:void 0!==n.encoding&&(a.encoding=n.encoding),void 0!==n.flipY&&(a.flipY=n.flipY),void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=A),1===n.mipmapCount&&(a.minFilter=E),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)}),n,i),a}}class Qo extends Xo{constructor(e){super(e)}load(e,t,n,i){const r=new We,a=new Ko(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)}),n,i),r}}class $o extends Qt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new gn(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 el=new At,tl=new Je,nl=new Je;class il{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new be(512,512),this.map=null,this.mapPass=null,this.matrix=new At,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Si,this._frameExtents=new be(1,1),this._viewportCount=1,this._viewports=[new je(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;tl.setFromMatrixPosition(e.matrixWorld),t.position.copy(tl),nl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(nl),t.updateMatrixWorld(),el.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(el),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(el)}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 rl extends il{constructor(){super(new hi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*pe*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class al extends $o{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Qt.DEFAULT_UP),this.updateMatrix(),this.target=new Qt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new rl}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 sl=new At,ol=new Je,ll=new Je;class cl extends il{constructor(){super(new hi(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new be(4,2),this._viewportCount=6,this._viewports=[new je(2,1,1,1),new je(0,1,1,1),new je(3,1,1,1),new je(1,1,1,1),new je(3,0,1,1),new je(1,0,1,1)],this._cubeDirections=[new Je(1,0,0),new Je(-1,0,0),new Je(0,0,1),new Je(0,0,-1),new Je(0,1,0),new Je(0,-1,0)],this._cubeUps=[new Je(0,1,0),new Je(0,1,0),new Je(0,1,0),new Je(0,1,0),new Je(0,0,1),new Je(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),ol.setFromMatrixPosition(e.matrixWorld),n.position.copy(ol),ll.copy(n.position),ll.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ll),n.updateMatrixWorld(),i.makeTranslation(-ol.x,-ol.y,-ol.z),sl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sl)}}class hl extends $o{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new cl}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 dl extends il{constructor(){super(new Oi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class ul extends $o{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Qt.DEFAULT_UP),this.updateMatrix(),this.target=new Qt,this.shadow=new dl}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class pl extends $o{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class fl extends $o{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class ml{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n{var t;switch(e.type){default:break;case"ambient":const n=new pl(new gn(e.color),0);this._lightSources.push(n);break;case"rectArea":const r=new Je(e.position.x,e.position.y,e.position.z);if(this.lightSourceScale&&r.length()this._scene.add(e)))}removeFromScene(){this._lightSources.forEach((e=>this._scene.remove(e)))}reload(){this.removeFromScene(),this.addToScene()}}Dl.noLightSources=[],Dl.defaultLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:3},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:3,z:2},color:"#ffffff",intensity:60,castShadow:!1}],Dl.fifeLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:0},color:"#ffffff",intensity:40,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0}];const Il={uniforms:{tDiffuse:{value:null},colorTransform:{value:new At},colorBase:{value:new je(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new Me}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = colorTransform * texture2D(tDiffuse, vUv) + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n gl_FragColor = color;\n }"},Nl=new At,Ol=(new At).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),Ul=(new At).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),Fl=(new At).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),Bl=((new At).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1),(new At).set(0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1),(new At).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1)),zl=new je(0,0,0,0),kl=new je(0,0,0,1),Hl=new Me,Vl=(new Me).set(1,0,0,0,-1,1,0,0,1),Gl=(e,t,n,i)=>(new At).set(e,0,0,1-e,0,t,0,1-t,0,0,n,1-n,0,0,0,i);var Wl;!function(e){e[e.DEFAULT=0]="DEFAULT",e[e.ADDITIVE=1]="ADDITIVE"}(Wl||(Wl={}));class jl extends li{constructor(e,t=Wl.ADDITIVE){const n=t===Wl.ADDITIVE?{blendSrc:208,blendDst:200,blendEquation:s,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:s}:{};super(Object.assign({uniforms:oi.clone(Il.uniforms),vertexShader:Il.vertexShader,fragmentShader:Il.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1},n)),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const Xl={uniforms:{tDiffuse:{value:null},rangeMin:{value:new be(1/512,1/512)},rangeMax:{value:new be(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new be(.1,.9),new be(.1,.9);class Yl extends li{constructor(e){super({defines:Object.assign({},Yl._linearDepthShader.defines),uniforms:oi.clone(Yl._linearDepthShader.uniforms),vertexShader:Yl._linearDepthShader.vertexShader,fragmentShader:Yl._linearDepthShader.fragmentShader,blending:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}Yl._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new je(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include \n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};class ql{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Zl=new Oi(-1,1,1,-1,0,1),Kl=new class extends Fn{constructor(){super(),this.setAttribute("position",new Cn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Cn([0,2,0,0,2,0],2))}};class Jl{constructor(e){this._mesh=new ti(Kl,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Zl)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Ql{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}dot4(e,t,n,i,r){return e[0]*t+e[1]*n+e[2]*i+e[3]*r}noise(e,t){let n,i,r;const a=(e+t)*(.5*(Math.sqrt(3)-1)),s=Math.floor(e+a),o=Math.floor(t+a),l=(3-Math.sqrt(3))/6,c=(s+o)*l,h=e-(s-c),d=t-(o-c);let u,p;h>d?(u=1,p=0):(u=0,p=1);const f=h-u+l,m=d-p+l,g=h-1+2*l,v=d-1+2*l,_=255&s,x=255&o,y=this.perm[_+this.perm[x]]%12,S=this.perm[_+u+this.perm[x+p]]%12,w=this.perm[_+1+this.perm[x+1]]%12;let b=.5-h*h-d*d;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[y],h,d));let M=.5-f*f-m*m;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[S],f,m));let T=.5-g*g-v*v;return T<0?r=0:(T*=T,r=T*T*this.dot(this.grad3[w],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s;const o=(e+t+n)*(1/3),l=Math.floor(e+o),c=Math.floor(t+o),h=Math.floor(n+o),d=1/6,u=(l+c+h)*d,p=e-(l-u),f=t-(c-u),m=n-(h-u);let g,v,_,x,y,S;p>=f?f>=m?(g=1,v=0,_=0,x=1,y=1,S=0):p>=m?(g=1,v=0,_=0,x=1,y=0,S=1):(g=0,v=0,_=1,x=1,y=0,S=1):fS?32:0)+(y>w?16:0)+(S>w?8:0)+(y>b?4:0)+(S>b?2:0)+(w>b?1:0),T=a[M][0]>=3?1:0,E=a[M][1]>=3?1:0,A=a[M][2]>=3?1:0,R=a[M][3]>=3?1:0,C=a[M][0]>=2?1:0,P=a[M][1]>=2?1:0,L=a[M][2]>=2?1:0,D=a[M][3]>=2?1:0,I=a[M][0]>=1?1:0,N=a[M][1]>=1?1:0,O=a[M][2]>=1?1:0,U=a[M][3]>=1?1:0,F=y-T+l,B=S-E+l,z=w-A+l,k=b-R+l,H=y-C+2*l,V=S-P+2*l,G=w-L+2*l,W=b-D+2*l,j=y-I+3*l,X=S-N+3*l,Y=w-O+3*l,q=b-U+3*l,Z=y-1+4*l,K=S-1+4*l,J=w-1+4*l,Q=b-1+4*l,$=255&m,ee=255&g,te=255&v,ne=255&_,ie=s[$+s[ee+s[te+s[ne]]]]%32,re=s[$+T+s[ee+E+s[te+A+s[ne+R]]]]%32,ae=s[$+C+s[ee+P+s[te+L+s[ne+D]]]]%32,se=s[$+I+s[ee+N+s[te+O+s[ne+U]]]]%32,oe=s[$+1+s[ee+1+s[te+1+s[ne+1]]]]%32;let le=.6-y*y-S*S-w*w-b*b;le<0?c=0:(le*=le,c=le*le*this.dot4(r[ie],y,S,w,b));let ce=.6-F*F-B*B-z*z-k*k;ce<0?h=0:(ce*=ce,h=ce*ce*this.dot4(r[re],F,B,z,k));let he=.6-H*H-V*V-G*G-W*W;he<0?d=0:(he*=he,d=he*he*this.dot4(r[ae],H,V,G,W));let de=.6-j*j-X*X-Y*Y-q*q;de<0?u=0:(de*=de,u=de*de*this.dot4(r[se],j,X,Y,q));let ue=.6-Z*Z-K*K-J*J-Q*Q;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(r[oe],Z,K,J,Q)),27*(c+h+d+u+p)}}const $l=new Qo,ec=e=>{const t=new Uint8Array([Math.floor(255*e.r),Math.floor(255*e.g),Math.floor(255*e.b),255]),n=new xs(t,1,1);return n.needsUpdate=!0,n},tc=(e,t,n)=>{n&&e(ec(n)),t&&$l.load(t,e)};class nc{constructor(){this.bounds=new et(new Je(-1,-1,-1),new Je(1,1,1)),this.size=new Je(2,2,2),this.center=new Je(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new Je(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Oi?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof hi&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),i=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const r=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),a=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=r/a,e.fov=we.radToDeg(2*Math.atan2(a,n)),e.near=n,e.far=i,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}const ic=e=>e.capabilities.maxSamples;class rc{changed(e){var t,n;const i=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),i}}const ac=e=>{const t=new Ql,n=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),i=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,i=Array(n).fill(0);let r=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)-1===r&&a===t?(a=t-2,r=0):(a===t&&(a=0),r<0&&(r=t-1)),0===i[r*t+a]?(i[r*t+a]=e++,a++,r--):(a-=2,r++);return i})(n),r=i.length,a=new Uint8Array(4*r);for(let n=0;n{let t=cc[e];if(!t){switch(e){default:case 2:t=new yo;break;case 0:t=new xo,t.opacity=.5;break;case 1:t=new yo,t.transparent=!0,t.opacity=0;break;case 3:{const e=new So;tc((t=>{dc(t),e.map=t}),"TexturesCom_Wood_ParquetChevron7_1K_albedo.jpg",new gn(1,.6,.2)),tc((t=>{dc(t),e.normalMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_normal.jpg"),tc((t=>{dc(t),e.roughnessMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_roughness.jpg"),e.aoMapIntensity=0,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}case 4:{const e=new So;tc((t=>{dc(t),e.map=t}),"TexturesCom_Pavement_HerringboneNew_1K_albedo.jpg",new gn(.6,.3,0)),tc((t=>{dc(t),e.normalMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_normal.jpg"),tc((t=>{dc(t),e.roughnessMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_roughness.jpg"),tc((t=>{dc(t),e.aoMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_ao.jpg"),e.aoMapIntensity=1,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}}cc[e]=t}return t},dc=e=>{e.anisotropy=16,e.wrapS=y,e.wrapT=y,e.repeat.set(1e5,1e5)},uc=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new be(t,n)};class pc{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new Ye,this._colorRenderTarget}environmentMapDecodeTarget(e){var t;const n=e.capabilities.isWebGL2?L:R;return this._environmentMapDecodeTarget=null!==(t=this._environmentMapDecodeTarget)&&void 0!==t?t:new Ye(1,1,{type:n}),this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new vc(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new vc(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Oi(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,i){var r;this.colorRenderTarget.setSize(n,i),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new ti(new Mi(2,2),new yn({map:t}));const a=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const s=this.environmentMapDecodeTarget(e).texture,o=new Uint8Array(n*i*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,i,o),{texture:s,pixels:o,sRgbaPixels:!1}}newGrayscaleTexture(e,t,n,i){var r;const a=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name),s=this.environmentMapDecodeTarget(e);s.setSize(n,i),a.setSourceTexture(t),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new ti(new Mi(2,2),a);const o=e.getRenderTarget();e.setRenderTarget(s),e.render(this._planeMesh,this.camera),e.setRenderTarget(o);const l=s.texture,c=s.texture.type===L;let h=c?new Float32Array(n*i*4):new Uint8Array(n*i*4);return e.readRenderTargetPixels(s,0,0,n,i,h),{texture:l,pixels:h,sRgbaPixels:c}}}const fc={tDiffuse:{value:null}},mc="\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",gc="\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }";class vc extends li{constructor(e,t){super({uniforms:oi.clone(fc),vertexShader:mc,fragmentShader:gc,defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}class _c{constructor(e){var t,n,i,r;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new We,pixels:new Uint8Array(0),sRgbaPixels:!1},this.detectorTexture=new We,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new yc(0),this.lightSources=[],this._grayScale=new Je(.2126,.7152,.0722),this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;nuc(e)))}detectLightSources(e,t,n){var i;this.textureData=n,this._textureConverter=null!==(i=this._textureConverter)&&void 0!==i?i:new pc,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels,this.grayscaleTexture.sRgbaPixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort(((e,t)=>t.maxIntensity-e.maxIntensity))}_redFromRgbaToNormalizedFloatArray(e,t,n){const i=new Float32Array(e.length/4);let r=1,a=0;for(let t=0;te&&t.push(new xc(this.samplePoints[n],i))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let i=0;for(let e=Math.max(0,t-2);e1){l=!1;break}}else c=0}l&&(r.adjacent[a].push(s),r.adjacent[s].push(a),r.edges.push([a,s]))}return r}createLightSourcesFromLightGraph(e,t){const n=t.components.filter((e=>e.length>1)).map((t=>new Sc(t.map((t=>e[t])))));return n.forEach((e=>e.calculateLightSourceProperties((e=>this._originalLuminanceValueFromUV(e))))),n}}class xc{constructor(e,t){this.position=e,this.uv=t}}class yc{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;tt.length-e.length))}_dfs(e,t,n){t[e]=!0,n.push(e);for(const i of this.adjacent[e])t[i]||this._dfs(i,t,n)}}class Sc{constructor(e){this.position=new Je,this.uv=new be,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new Je,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=uc(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class wc{constructor(e){this._lightSourceDetector=e}static createPlane(e,t){const n=new Mi(2,1),i=null!=t?t:new yn({color:12632256,side:2}),r=new ti(n,i);return r.position.z=-.1,e.add(r),r}createDebugScene(e,t){this._scene=e,this._createLightGraphInMap(this._lightSourceDetector.sampleUVs,this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph,t)}_createLightGraphInMap(e,t,n,i){let r=[],a=[];for(let e=0;ee.uv)),o=a.map((e=>e.uv)),l=e.filter((e=>!s.includes(e)&&!o.includes(e)));this._createSamplePointsInMap(l,.005,16711680),this._createSamplePointsInMap(s,.01,255),this._createSamplePointsInMap(o,.01,65280),this._createClusterLinesInMap(this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph.edges,128);const c=this._lightSourceDetector.lightSources.map((e=>e.uv));this._createSamplePointsInMap(c,.015,16776960);let h=this._lightSourceDetector.lightSources;void 0!==i&&i>=0&&i{var t;const n=new ti(i,r);n.position.copy(this._uvToMapPosition(e)),n.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(n)}))}_createCirclesInMap(e,t){const n=new yn({color:t,transparent:!0,opacity:.5});e.forEach((e=>{var t;const i=new co(e.size,8,4),r=new ti(i,n);r.position.copy(this._uvToMapPosition(e.uv)),r.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(r)}))}_createClusterLinesInMap(e,t,n){var i;const r=new Ds({color:n}),a=[];t.forEach((t=>{for(let n=1;n.5){const e=(i.y+r.y)/2,t=i.x{(new Zo).setResponseType("arraybuffer").load(this._path+e,(e=>{this.parseData_(e),t(this._cubeTexture)}))}))}parseHeader_(e){let t=new DataView(e,0,30);this._size=t.getUint16(0),this._maxLod=t.getUint8(2),this._colorSpace=t.getUint16(3)?K:Z,this._type=t.getUint16(5),this._format=t.getUint16(7),this._lightDirection.x=t.getFloat32(9),this._lightDirection.y=t.getFloat32(13),this._lightDirection.z=t.getFloat32(17)}parseBufferData_(e,t){let n=this._size;const i=Math.log2(this._size)+1;this._cubeTextures=[];for(let r=0;r{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function Pc(e){const t=new yn;return t.color.setScalar(e),t}var Lc=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(Lc(""))}catch(e){Lc=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var Dc=Uint8Array,Ic=Uint16Array,Nc=Uint32Array,Oc=new Dc([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]),Uc=new Dc([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]),Fc=new Dc([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Bc=function(e,t){for(var n=new Ic(31),i=0;i<31;++i)n[i]=t+=1<>>1|(21845&jc)<<1;Xc=(61680&(Xc=(52428&Xc)>>>2|(13107&Xc)<<2))>>>4|(3855&Xc)<<4,Wc[jc]=((65280&Xc)>>>8|(255&Xc)<<8)>>>1}var Yc=function(e,t,n){for(var i=e.length,r=0,a=new Ic(t);r>>l]=c}else for(s=new Ic(i),r=0;r>>15-e[r]);return s},qc=new Dc(288);for(jc=0;jc<144;++jc)qc[jc]=8;for(jc=144;jc<256;++jc)qc[jc]=9;for(jc=256;jc<280;++jc)qc[jc]=7;for(jc=280;jc<288;++jc)qc[jc]=8;var Zc=new Dc(32);for(jc=0;jc<32;++jc)Zc[jc]=5;var Kc=Yc(qc,9,1),Jc=Yc(Zc,5,1),Qc=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},$c=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},eh=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},th=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Dc(0);var r=!t||n,a=!n||n.i;n||(n={}),t||(t=new Dc(3*i));var s,o=function(e){var n=t.length;if(e>n){var i=new Dc(Math.max(2*n,e));i.set(t),t=i}},l=n.f||0,c=n.p||0,h=n.b||0,d=n.l,u=n.d,p=n.m,f=n.n,m=8*i;do{if(!d){n.f=l=$c(e,c,1);var g=$c(e,c+1,3);if(c+=3,!g){var v=e[(s=c,(R=(s/8|0)+(7&s&&1)+4)-4)]|e[R-3]<<8,_=R+v;if(_>i){if(a)throw"unexpected EOF";break}r&&o(h+v),t.set(e.subarray(R,_),h),n.b=h+=v,n.p=c=8*_;continue}if(1==g)d=Kc,u=Jc,p=9,f=5;else{if(2!=g)throw"invalid block type";var x=$c(e,c,31)+257,y=$c(e,c+10,15)+4,S=x+$c(e,c+5,31)+1;c+=14;for(var w=new Dc(S),b=new Dc(19),M=0;M>>4)<16)w[M++]=R;else{var P=0,L=0;for(16==R?(L=3+$c(e,c,3),c+=2,P=w[M-1]):17==R?(L=3+$c(e,c,7),c+=3):18==R&&(L=11+$c(e,c,127),c+=7);L--;)w[M++]=P}}var D=w.subarray(0,x),I=w.subarray(x);p=Qc(D),f=Qc(I),d=Yc(D,p,1),u=Yc(I,f,1)}if(c>m){if(a)throw"unexpected EOF";break}}r&&o(h+131072);for(var N=(1<>>4;if((c+=15&P)>m){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(F<256)t[h++]=F;else{if(256==F){U=c,d=null;break}var B=F-254;if(F>264){var z=Oc[M=F-257];B=$c(e,c,(1<>>4;if(!k)throw"invalid distance";if(c+=15&k,I=Gc[H],H>3&&(z=Uc[H],I+=eh(e,c)&(1<m){if(a)throw"unexpected EOF";break}r&&o(h+131072);for(var V=h+B;he.length)&&(n=e.length);var i=new(e instanceof Ic?Ic:e instanceof Nc?Nc:Dc)(n-t);return i.set(e.subarray(t,n)),i}(t,0,h)},nh=new Dc(0);function ih(e,t){return th((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}var rh,ah="undefined"!=typeof TextDecoder&&new TextDecoder;try{ah.decode(nh,{stream:!0})}catch(e){}class sh extends Jo{constructor(e){super(e),this.type=D}parse(e){const t=65536,n=14,i=65537,r=Math.pow(2.7182818,2.2),a={l:0,c:0,lc:0};function s(e,t,n,i,r){for(;n>n&(1<>6}const h={c:0,lc:0};function d(e,t,n,i){e=e<<8|H(n,i),t+=8,h.c=e,h.lc=t}const u={c:0,lc:0};function p(e,t,n,i,r,a,s,o,l){if(e==t){i<8&&(d(n,i,r,a),n=h.c,i=h.lc);let e=n>>(i-=8);if(e=new Uint8Array([e])[0],o.value+e>l)return!1;const t=s[o.value-1];for(;e-- >0;)s[o.value++]=t}else{if(!(o.value32767?t-65536:t}const g={a:0,b:0};function v(e,t){const n=m(e),i=m(t),r=n+(1&i)+(i>>1),a=r,s=r-i;g.a=a,g.b=s}function _(e,t){const n=f(e),i=f(t),r=n-(i>>1)&65535,a=i+r-32768&65535;g.a=a,g.b=r}function x(e,t,n,i,r,a,s){const o=s<16384,l=n>r?r:n;let c,h,d=1;for(;d<=l;)d<<=1;for(d>>=1,c=d,d>>=1;d>=1;){h=0;const s=h+a*(r-c),l=a*d,u=a*c,p=i*d,f=i*c;let m,x,y,S;for(;h<=s;h+=u){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p,i=r+l,a=i+p;o?(v(e[r+t],e[i+t]),m=g.a,y=g.b,v(e[n+t],e[a+t]),x=g.a,S=g.b,v(m,x),e[r+t]=g.a,e[n+t]=g.b,v(y,S),e[i+t]=g.a,e[a+t]=g.b):(_(e[r+t],e[i+t]),m=g.a,y=g.b,_(e[n+t],e[a+t]),x=g.a,S=g.b,_(m,x),e[r+t]=g.a,e[n+t]=g.b,_(y,S),e[i+t]=g.a,e[a+t]=g.b)}if(n&d){const n=r+l;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}if(r&d){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}c=d,d>>=1}return h}function y(e,t,r,f,m,g){const v=r.value,_=k(t,r),x=k(t,r);r.value+=4;const y=k(t,r);if(r.value+=4,_<0||_>=i||x<0||x>=i)throw new Error("Something wrong with HUF_ENCSIZE");const S=new Array(i),w=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(w),function(e,t,n,r,l,c){const h=t;let d=0,u=0;for(;r<=l;r++){if(h.value-t.value>n)return!1;s(6,d,u,e,h);const i=a.l;if(d=a.c,u=a.lc,c[r]=i,63==i){if(h.value-t.value>n)throw new Error("Something wrong with hufUnpackEncTable");s(8,d,u,e,h);let i=a.l+6;if(d=a.c,u=a.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let e=i-59+2;if(r+e>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)c[r++]=0;r--}}!function(e){for(let e=0;e<=58;++e)o[e]=0;for(let t=0;t0;--e){const n=t+o[e]>>1;o[e]=t,t=n}for(let t=0;t0&&(e[t]=n|o[n]++<<6)}}(c)}(e,r,f-(r.value-v),_,x,S),y>8*(f-(r.value-v)))throw new Error("Something wrong with hufUncompress");!function(e,t,i,r){for(;t<=i;t++){const i=c(e[t]),a=l(e[t]);if(i>>a)throw new Error("Invalid table entry");if(a>n){const e=r[i>>a-n];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n0;s--){const s=r[(i<=n;){const a=t[g>>v-n&16383];if(a.len)v-=a.len,p(a.lit,s,g,v,i,r,f,m,_),g=u.c,v=u.lc;else{if(!a.p)throw new Error("hufDecode issues");let t;for(t=0;t=n&&c(e[a.p[t]])==(g>>v-n&(1<>=y,v-=y;v>0;){const e=t[g<a||(t[r++]=e[n++],r>a));)t[r++]=e[i++]}function b(e){let t=e.byteLength;const n=new Array;let i=0;const r=new DataView(e);for(;t>0;){const e=r.getInt8(i++);if(e<0){const a=-e;t-=a+1;for(let e=0;e>8==255?r+=255&i:(n[r]=i,r++),e.value++}function T(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(.981746875),s=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),d=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=i*e[p+2],l[1]=s*e[p+2],l[2]=i*e[p+6],l[3]=s*e[p+6],c[0]=n*e[p+1]+r*e[p+3]+a*e[p+5]+o*e[p+7],c[1]=r*e[p+1]-o*e[p+3]-n*e[p+5]-a*e[p+7],c[2]=a*e[p+1]-n*e[p+3]+o*e[p+5]+r*e[p+7],c[3]=o*e[p+1]-a*e[p+3]+r*e[p+5]-n*e[p+7],h[0]=t*(e[p+0]+e[p+4]),h[3]=t*(e[p+0]-e[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[p+0]=d[0]+c[0],e[p+1]=d[1]+c[1],e[p+2]=d[2]+c[2],e[p+3]=d[3]+c[3],e[p+4]=d[3]-c[3],e[p+5]=d[2]-c[2],e[p+6]=d[1]-c[1],e[p+7]=d[0]-c[0]}for(let u=0;u<8;++u)l[0]=i*e[16+u],l[1]=s*e[16+u],l[2]=i*e[48+u],l[3]=s*e[48+u],c[0]=n*e[8+u]+r*e[24+u]+a*e[40+u]+o*e[56+u],c[1]=r*e[8+u]-o*e[24+u]-n*e[40+u]-a*e[56+u],c[2]=a*e[8+u]-n*e[24+u]+o*e[40+u]+r*e[56+u],c[3]=o*e[8+u]-a*e[24+u]+r*e[40+u]-n*e[56+u],h[0]=t*(e[u]+e[32+u]),h[3]=t*(e[u]-e[32+u]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[0+u]=d[0]+c[0],e[8+u]=d[1]+c[1],e[16+u]=d[2]+c[2],e[24+u]=d[3]+c[3],e[32+u]=d[3]-c[3],e[40+u]=d[2]-c[2],e[48+u]=d[1]-c[1],e[56+u]=d[0]-c[0]}function E(e){for(let t=0;t<64;++t){const n=e[0][t],i=e[1][t],r=e[2][t];e[0][t]=n+1.5747*r,e[1][t]=n-.1873*i-.4682*r,e[2][t]=n+1.8556*i}}function A(e,t,n){for(let a=0;a<64;++a)t[n+a]=bn.toHalfFloat((i=e[a])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function R(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function C(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(b(t)),i=new Uint8Array(n.length);return S(n),w(n,i),new DataView(i.buffer)}function P(e){const t=ih(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return S(t),w(t,n),new DataView(n.buffer)}function I(e){const n=e.viewer,i={value:e.offset.value},r=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),a=new Uint8Array(8192);let s=0;const o=new Array(e.channels);for(let t=0;t=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let e=0;e>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const e=B(t.buffer,n),i=V(t,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=V(t,n);a.push({name:e,index:o,type:l,compression:r}),s-=e.length+3}const o=te.channels,l=new Array(e.channels);for(let t=0;t=0&&(c.idx[i.index]=t),e.offset=t)}}let h,d,u;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),y(e.array,t,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=ih(e.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const t={array:e.array,offset:n,size:r.dcCompressedSize};d=new Uint16Array(P(t).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(u=b(ih(e.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let e=0;e>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function Y(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function Z(e,t){return X(Y(e,t))}function J(e,t,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(e,t,n){const i=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,i}(t,n,r):"chlist"===i?function(e,t,n,i){const r=n.value,a=[];for(;n.valuene.height?ne.height-t:ne.scanlineBlockSize;const n=ne.size=ne.height)break;for(let e=0;e(r=o.indexOf("\n"))&&a=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(c=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(a))&&(o.valid|=2,o.format=c[1]),(c=l.match(s))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(a),o=s.width,l=s.height,c=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);r!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const a=new Uint8Array(4*n*i);a.length||t(4,"unable to allocate buffer space");let s=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let d=i;for(;d>0&&oe.byteLength&&t(1),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])==r||t(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&t(3,"bad scanline data"),r){const t=e[o++];for(let e=0;e0?this.environmentName:r),s=this.currentEnvironment!==a;return this.showBackground=null!==(i=null==t?void 0:t.showEnvironment)&&void 0!==i&&i,this.currentEnvironment=a,this.currentEnvironment&&(null==t?void 0:t.environmentRotation)&&(this.currentEnvironment.rotation=t.environmentRotation),this.currentEnvironment&&(null==t?void 0:t.environmentIntensity)&&(this.currentEnvironment.intensity=t.environmentIntensity),e.userData.showEnvironmentBackground=this.showBackground,e.userData.environmentDefinition=this.currentEnvironment,s}loadDefaultEnvironment(e,t,n){var i;const r=null!=n?n:"room environment",a=null!==(i=t&&t())&&void 0!==i?i:new lh;this.environemtMap.set(r,new Ac(a)),e&&(this.environmentName=r),this.updateUI()}loadEnvmap(e,t,n){this.loadAndSetCubeTexture((t=>{this.environemtMap.set(e,new Ac(t)),n&&(this.environmentName=e),this.updateUI()}),t)}loadExr(e,t,n){this.loadExrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Ac(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadHdr(e,t,n){this.loadHdrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Ac(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadAndSetCubeTexture(e,t){t&&(this.envMapReader||(this.envMapReader=new Rc),this.envMapReader.load(t).then((t=>{t&&e(t)})))}loadExrAndSetTexture(e,t){t&&(this.exrLoader||(this.exrLoader=new sh),this.exrLoader.load(t,((t,n)=>{e(t,n)})))}loadHdrAndSetTexture(e,t){t&&(this.rgbeLoader||(this.rgbeLoader=new oh),this.rgbeLoader.load(t,((t,n)=>{e(t,n)})))}addGUI(e){this.uiFolder=e,this.updateUI()}updateUI(){if(this.uiFolder){const e=Array.from(this.environemtMap.keys());if(this.environmentController){let t="";e.forEach((e=>{t+=``})),this.environmentController.domElement.children[0].innerHTML=t,this.environmentController.setValue(this.environmentName),this.environmentController.updateDisplay()}else this.environmentController=this.uiFolder.add(this,"environmentName",e)}}}class hh extends ti{constructor(){const e=hh.SkyShader,t=new li({name:e.name,uniforms:oi.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:1,depthWrite:!1});super(new ii(1,1,1),t),this.isSky=!0}}hh.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new Je},up:{value:new Je(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPosition );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t}"};class dh{constructor(e){this.sky=new hh,this.sky.name="Sky",this.parameters=Object.assign({visible:!0,distance:4e5,turbidity:10,rayleigh:2,mieCoefficient:.005,mieDirectionalG:.8,inclination:.6,azimuth:0},e),this.updateSky()}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateSky(){this.sky.scale.setScalar(45e4),this.sky.frustumCulled=!1,this.sky.material.uniforms.turbidity.value=this.parameters.turbidity,this.sky.material.uniforms.rayleigh.value=this.parameters.rayleigh,this.sky.material.uniforms.mieCoefficient.value=this.parameters.mieCoefficient,this.sky.material.uniforms.mieDirectionalG.value=this.parameters.mieDirectionalG;let e=(t=this.parameters.distance,n=this.parameters.azimuth,i=this.parameters.inclination,(new Je).setFromSphericalCoords(t,Math.PI*(1-i),2*Math.PI*(1-n)));var t,n,i;this.sky.material.uniforms.sunPosition.value.copy(e),this.sky.visible=this.parameters.visible}addToScene(e){e.add(this.sky)}changeVisibility(e){this.parameters.visible!==e&&(this.updateParameters({visible:e}),this.updateSky())}}!function(e){e[e.None=0]="None",e[e.GridPaper=1]="GridPaper",e[e.Concrete=2]="Concrete",e[e.Marble=3]="Marble",e[e.Granite=4]="Granite",e[e.VorocracksMarble=5]="VorocracksMarble",e[e.Kraft=6]="Kraft",e[e.Line=7]="Line",e[e.Test=8]="Test"}(rh||(rh={}));class uh{get isSet(){return this.parameters.backgroundType!==rh.None}constructor(e){this._materialMap=new Map;const t=new Fn;t.setAttribute("position",new Cn([-1,3,0,-1,-1,0,3,-1,0],3)),t.setAttribute("uv",new Cn([0,2,0,0,2,0],2)),this.backgroundMesh=new ti(t),this.backgroundMesh.name="Background",this.parameters=Object.assign({visible:!1,backgroundType:rh.None},e),this.updateBackground()}_updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBackground(){this.backgroundMesh.visible=this.parameters.backgroundType!==rh.None,this.backgroundMaterial=this._getMaterial(),this.backgroundMesh.material=this.backgroundMaterial}update(e,t,n){this.backgroundMesh.visible&&this.backgroundMaterial&&(this.backgroundMaterial.uniforms.viewMatrixInverse.value.copy(n.matrixWorld),this.backgroundMaterial.uniforms.projectionMatrixInverse.value.copy(n.projectionMatrixInverse),this.backgroundMaterial.uniforms.iResolution.value.set(e,t))}addToScene(e){this.backgroundMesh!==e&&e.add(this.backgroundMesh)}hideBackground(){this.parameters.backgroundType!==rh.None&&(this.parameters.backgroundType=rh.None,this.updateBackground())}_getMaterial(){let e=this._materialMap.get(this.parameters.backgroundType);if(e)return e;let t=fh,n={};switch(this.parameters.backgroundType){default:break;case rh.Test:t=fh;break;case rh.GridPaper:t=mh;break;case rh.Concrete:t=gh,n={patternChoice:1};break;case rh.Marble:t=gh,n={patternChoice:3};break;case rh.Granite:t=gh,n={patternChoice:6};break;case rh.VorocracksMarble:t=vh;break;case rh.Kraft:t=_h;break;case rh.Line:t=xh}return e=new li({name:"BackgroundShader",vertexShader:ph,fragmentShader:t,defines:n,uniforms:{viewMatrixInverse:{value:new At},projectionMatrixInverse:{value:new At},scale:{value:8},iResolution:{value:new be(1024,1024)}},side:2,depthWrite:!1}),this._materialMap.set(this.parameters.backgroundType,e),e}}const ph="varying vec2 vertexUv;\nuniform mat4 viewMatrixInverse;\nuniform mat4 projectionMatrixInverse;\nuniform float scale;\n\nvoid main() {\n vec4 p = viewMatrixInverse * projectionMatrixInverse * vec4(position.xy, 0.0, 1.0);\n vertexUv = (p.xz / p.w * 0.5 + 0.5) / scale; \n gl_Position = vec4(position.xy, 1.0, 1.0);\n}",fh="varying vec2 vertexUv;\nvoid main() {\n vec2 uv = fract(vertexUv);\n gl_FragColor = vec4(uv.x, uv.y, (1.0-uv.x) * (1.0 - uv.y), 1.0);\n}",mh="varying vec2 vertexUv;\nuniform vec2 iResolution;\nfloat nsin(float a)\n{\n return (sin(a)+1.)/2.;\n}\nfloat rand(float n)\n{\n \treturn fract(cos(n*89.42)*343.42);\n}\nvec2 rand(vec2 n)\n{\n \treturn vec2(rand(n.x*23.62-300.0+n.y*34.35),rand(n.x*45.13+256.0+n.y*38.89)); \n}\n\n// returns (dx, dy, distance)\nvec3 worley(vec2 n,float s)\n{\n vec3 ret = vec3(s * 10.);\n // look in 9 cells (n, plus 8 surrounding)\n for(int x = -1;x<2;x++)\n {\n for(int y = -1;y<2;y++)\n {\n vec2 xy = vec2(x,y);// xy can be thought of as both # of cells distance to n, and \n vec2 cellIndex = floor(n/s) + xy;\n vec2 worleyPoint = rand(cellIndex);// random point in this cell (0-1)\n worleyPoint += xy - fract(n/s);// turn it into distance to n. ;\n float d = length(worleyPoint) * s;\n if(d < ret.z)\n ret = vec3(worleyPoint, d);\n }\n }\n return ret;\n}\n\nvec2 mouse = vec2(1.);// how do i initialize this??\n\nvec4 applyLighting(vec4 inpColor, vec2 uv, vec3 normal, vec3 LightPos, vec4 LightColor, vec4 AmbientColor)\n{\n // if(distance(uv.xy, LightPos.xy) < 0.01) return vec4(1.,0.,0.,1.);\n vec3 LightDir = vec3(LightPos.xy - uv, LightPos.z);\n vec3 N = normalize(normal);\n vec3 L = normalize(LightDir);\n vec3 Diffuse = (LightColor.rgb * LightColor.a) * max(dot(N, L), 0.0);\n vec3 Ambient = AmbientColor.rgb * AmbientColor.a;\n vec3 Intensity = Ambient + Diffuse;\n vec3 FinalColor = inpColor.rgb * Intensity;\n return vec4(FinalColor, inpColor.a);\n}\n\n// convert distance to alpha value (see https://www.shadertoy.com/view/ltBGzt)\nfloat dtoa(float d)\n{\n const float amount = 800.0;\n return clamp(1.0 / (clamp(d, 1.0/amount, 1.0)*amount), 0.,1.);\n}\n\n// distance to edge of grid line. real distance, and centered over its position.\nfloat grid_d(vec2 uv, vec2 gridSize, float gridLineWidth)\n{\n uv += gridLineWidth / 2.0;\n uv = mod(uv, gridSize);\n vec2 halfRemainingSpace = (gridSize - gridLineWidth) / 2.0;\n uv -= halfRemainingSpace + gridLineWidth;\n uv = abs(uv);\n uv = -(uv - halfRemainingSpace);\n return min(uv.x, uv.y);\n}\n// centered over lineposy\nfloat hline_d(vec2 uv, float lineposy, float lineWidth)\n{\n\treturn distance(uv.y, lineposy) - (lineWidth / 2.0);\n}\n// centered over lineposx\nfloat vline_d(vec2 uv, float lineposx, float lineWidth)\n{\n\treturn distance(uv.x, lineposx) - (lineWidth / 2.0);\n}\nfloat circle_d(vec2 uv, vec2 center, float radius)\n{\n\treturn length(uv - center) - radius;\n}\n\n// not exactly perfectly perfect, but darn close\nfloat pointRectDist(vec2 p, vec2 rectTL, vec2 rectBR)\n{\n float dx = max(max(rectTL.x - p.x, 0.), p.x - rectBR.x);\n float dy = max(max(rectTL.y - p.y, 0.), p.y - rectBR.y);\n return max(dx, dy);\n}\n\n\nvec2 getuv(vec2 fragCoord, vec2 newTL, vec2 newSize, out float distanceToVisibleArea, out float vignetteAmt)\n{\n vec2 ret = vec2(fragCoord.x / iResolution.x, (iResolution.y - fragCoord.y) / iResolution.y);// ret is now 0-1 in both dimensions\n \n // warp\n //ret = tvWarp(ret / 2.) * 2.;// scale it by 2.\n distanceToVisibleArea = pointRectDist(ret, vec2(0.0), vec2(1.));\n\n // vignette\n vec2 vignetteCenter = vec2(0.5, 0.5);\n\tvignetteAmt = 1.0 - distance(ret, vignetteCenter);\n vignetteAmt = 0.03 + pow(vignetteAmt, .25);// strength\n vignetteAmt = clamp(vignetteAmt, 0.,1.);\n \n \n ret *= newSize;// scale up to new dimensions\n float aspect = iResolution.x / iResolution.y;\n ret.x *= aspect;// orig aspect ratio\n float newWidth = newSize.x * aspect;\n return ret + vec2(newTL.x - (newWidth - newSize.x) / 2.0, newTL.y);\n}\n\nvec4 drawHole(vec4 inpColor, vec2 uv, vec2 pos)\n{\n vec4 circleWhiteColor = vec4(vec3(0.95), 1.);\n\tfloat d = circle_d(uv, pos, 0.055);\n return vec4(mix(inpColor.rgb, circleWhiteColor.rgb, circleWhiteColor.a * dtoa(d)), 1.);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n float distanceToVisibleArea;\n float vignetteAmt;\n\tvec2 uv = getuv(fragCoord, vec2(-1.,1.), vec2(2., -2.), distanceToVisibleArea, vignetteAmt);\n float throwaway;\n //mouse = getuv(iMouse.xy, vec2(-1.,1.), vec2(2., -2.), throwaway, throwaway);\n\n fragColor = vec4(0.94, 0.96, 0.78, 1.0);// background\n float d;\n \n // grid\n vec4 gridColor = vec4(0.2,0.4,.9, 0.35);\n\td = grid_d(uv, vec2(0.10), 0.001);\n\tfragColor = vec4(mix(fragColor.rgb, gridColor.rgb, gridColor.a * dtoa(d)), 1.);\n \n // red h line\n //vec4 hlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = hline_d(uv, 0.60, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, hlineColor.rgb, hlineColor.a * dtoa(d)), 1.);\n \n // red v line\n //vec4 vlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = vline_d(uv, -1.40, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, vlineColor.rgb, vlineColor.a * dtoa(d)), 1.);\n\n \n // fractal worley crumpled paper effect\n float wsize = 0.8;\n const int iterationCount = 6;\n vec2 normal = vec2(0.);\n float influenceFactor = 1.0;\n for(int i = 0; i < iterationCount; ++ i)\n {\n vec3 w = worley(uv, wsize);\n\t\tnormal.xy += influenceFactor * w.xy;\n wsize *= 0.5;\n influenceFactor *= 0.9;\n }\n \n // lighting\n //vec3 lightPos = vec3(mouse, 8.);\n //vec4 lightColor = vec4(vec3(0.99),0.6);\n //vec4 ambientColor = vec4(vec3(0.99),0.5);\n\t//fragColor = applyLighting(fragColor, uv, vec3(normal, 4.0), lightPos, lightColor, ambientColor);\n\n // white circles\n //fragColor = drawHole(fragColor, uv, vec2(-1.6, 0.2));\n\t//fragColor = drawHole(fragColor, uv, vec2(-1.6, -.7));\n \n // post effects\n\t//fragColor.rgb *= vignetteAmt;\n gl_FragColor = fragColor;\n}",gh="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n\n// Solid Colors\nvec3 red = vec3(1.0,0.0,0.0);\nvec3 green = vec3(0.0,1.0,0.0);\nvec3 blue = vec3(0.0,0.0,1.0);\nvec3 black = vec3(0.0,0.0,0.0);\nvec3 white = vec3(1.0,1.0,1.0);\n// Concrete\nvec3 concreteLite = vec3(0.909, 0.905, 0.917);\nvec3 concreteDark = vec3(0.760, 0.729, 0.647);\n// Lava\nvec3 lavaLite = vec3(0.686, 0.203, 0.160);\nvec3 lavaDark = vec3(0.580, 0.176, 0.117);\n// Marble\nvec3 marbleLite = vec3(0.988, 0.988, 0.988);\nvec3 marbleStainBlue1 = vec3(0.690, 0.760, 0.811);\nvec3 marbleStainBlue2 = vec3(0.647, 0.745, 0.803);\nvec3 marbleStainBlue3 = vec3(0.654, 0.756, 0.772);\n// Lava Lamp\nvec3 lavaLampBG = vec3(0.462, 0.266, 0.6);\nvec3 lavaLampLava = vec3(0.929, 0.203, 0.572);\n// Clouds\nvec3 sky = vec3(0.541, 0.729, 0.827);\nvec3 cloud = vec3(0.941, 0.945, 0.941);\n// Granite\nvec3 graniteBG = vec3(0.956, 0.952, 0.976);\nvec3 graniteGray = vec3(0.478, 0.474, 0.494);\nvec3 graniteBrown = vec3(0.4, 0.356, 0.341);\nvec3 graniteBlack = vec3(0.105, 0.121, 0.160);\n\n// Tartan\nvec3 tar1Blue = vec3(0.074, 0.349, 0.505);\nvec3 tar1Green = vec3(0.286, 0.541, 0.341);\nvec3 tar1White = vec3(1.0,1.0,1.0);\nvec3 tar1Black = vec3(0.0,0.0,0.0);\nvec3 tar1BG = vec3(0.062, 0.274, 0.109);\n\n// Tartan 2\nvec3 tar2BG = vec3(0.152, 0.160, 0.156);\nvec3 tar2Blue = vec3(0.176, 0.501, 0.674);\nvec3 tar2Orange = vec3(0.603, 0.407, 0.309);\n\n// Art Installation\nvec3 violet = vec3(0.662, 0.407, 0.870);\nvec3 yellow = vec3(0.968, 0.752, 0.556);\n\n\nfloat random (in vec2 uv) {\n return fract(sin(dot(uv.xy,\n vec2(12.9898,78.233)))*\n 43758.5453123);\n}\n\n// Based on Morgan McGuire @morgan3d\n// https://www.shadertoy.com/view/4dS3Wd\nfloat noise (in vec2 uv) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n\n // Four corners in 2D of a tile\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(a, b, u.x) +\n (c - a)* u.y * (1.0 - u.x) +\n (d - b) * u.x * u.y;\n}\n\n#define OCTAVES 6\nfloat fbm (in vec2 uv) {\n // Initial values\n float value = 0.0;\n float amplitud = .5;\n float frequency = 0.;\n //\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitud * noise(uv);\n uv *= 2.;\n amplitud *= .5;\n }\n return value;\n}\n\n// Simplex noise\nvec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); }\n\nfloat snoise(vec2 v) {\n const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439); // 1.0 / 41.0\n vec2 i = floor(v + dot(v, C.yy) );\n vec2 x0 = v - i + dot(i, C.xx);\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n i = mod289(i); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))\n + i.x + vec3(0.0, i1.x, 1.0 ));\n\n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m ;\n m = m*m ;\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n\nfloat lavaLamp(vec2 uv,vec2 shapePos, float times){\n shapePos = vec2(shapePos.x*1.5,shapePos.y*0.3);\n uv -= shapePos;\n \n float angle = atan(uv.y,uv.x);\n float radius = cos(times*angle*0.5);\n return radius;\n}\n\nvec4 rectangle(vec2 uv, vec2 pos, float width, float height, vec3 color) {\n\tfloat t = 0.0;\n\tif ((uv.x > pos.x - width / 2.0) && (uv.x < pos.x + width / 2.0)\n\t\t&& (uv.y > pos.y - height / 2.0) && (uv.y < pos.y + height / 2.0)) {\n\t\tt = 1.0;\n\t}\n\treturn vec4(color, t);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n\tvec2 uv = fragCoord.xy / iResolution.xy;\n\tfloat ratio = iResolution.x/iResolution.y;\n uv.x *= ratio;\n \n if (patternChoice == 1) // Concrete\n {\n vec3 value = concreteLite;\n \n value = mix(value, concreteDark,random(uv)*0.6);\n value = mix(value, black, random(uv)*0.35);\n \n vec3 stains = vec3(fbm((uv*5.)*2.))*.12;\n \n value = mix(value, concreteLite,(smoothstep(0.03,.12,stains) - smoothstep(.2,.3,stains))*0.3);\n \n\t fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 2) // Lava\n {\n\t\tvec3 value = black;\n \n vec3 stains = vec3(fbm((uv*1.7)*25.))*.75;\n \n float fade = sin(iTime * 5.)+2.5;\n \n value = mix(value, lavaLite, (smoothstep(0.05,0.1,stains) - smoothstep(.17, .22,stains) * fade));\n \n fragColor = vec4(value,1.0);\n }\n \n else if (patternChoice == 3) // Marble\n {\n vec3 value = marbleLite;\n \n vec3 stains = vec3(fbm((uv*1.2)*18.))*.113;\n vec3 stains2 = vec3(fbm((uv*5.)*1.5))*.12;\n \n vec3 stains3 = vec3(fbm((uv)*5.))*.12;\n vec3 stains4 = vec3(fbm((uv*2.)*2.5))*.12;\n \n value = mix(value, marbleStainBlue1,(smoothstep(0.065,0.1,stains) - smoothstep(0.1, 0.8,stains)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.065,0.1,stains2) - smoothstep(0.1, 0.8,stains2)));\n //value = mix(value, marbleStainBlue3,(smoothstep(0.09,0.1,stains2) - smoothstep(0.2, 0.5,stains2)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.07,0.1,stains3) - smoothstep(0.1, 0.8,stains3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 4) // Lava Lamp\n {\n //float value = lavaLamp(uv,vec2(0.,0.5), 3.);\n //vec2 value = vec2(snoise(uv*3.-iTime));\n \t//vec3 color = red*vec3(value, 1.0);\n \n vec3 value = lavaLampBG;\n float lava = lavaLamp(uv*0.5,vec2(snoise(uv*4.-iTime)), 1.);\n \n vec3 color = lavaLampLava*lava;\n value += color;\n \n \n fragColor = vec4(value, 1.0);\n }\n \t\n else if (patternChoice == 5) // Clouds\n {\n uv *= 0.5;\n vec3 value = sky;\n \n vec3 clouds = vec3(fbm((uv*sin(iTime*0.25))*20.))*.12;\n \n value = mix(value, cloud,(smoothstep(0.05,0.1,clouds) - smoothstep(0.1, 0.2,clouds)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 6) // Granite\n {\n \tvec3 value = graniteBG;\n \n uv *= 2.;\n uv += 2.3;\n vec3 layer1 = vec3(fbm((uv*0.6)*18.))*.113;\n uv *= 0.2;\n uv += 0.5;\n vec3 layer2 = vec3(fbm((uv*0.8)*30.))*.117;\n uv *= 2.2;\n uv += 2.5;\n vec3 layer3 = vec3(fbm((uv*0.4)*15.))*.12;\n \n value = mix(value, graniteBlack,(smoothstep(0.04,0.1,layer1) - smoothstep(0.1, 0.8,layer1)));\n value = mix(value, graniteBrown,(smoothstep(0.04,0.1,layer2) - smoothstep(0.1, 0.8,layer2)));\n value = mix(value, graniteGray,(smoothstep(0.072,0.1,layer3) - smoothstep(0.1, 0.8,layer3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 7) // Scottish Tartan 1\n {\n vec3 value = tar1BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float whiteTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // White lines\n // Vertical\n whiteTile += step(0.0001, uv.x) - step(0.02, uv.x);\n whiteTile += step(0.49, uv.x) - step(0.51, uv.x);\n // Horizontal\n whiteTile += step(0.220, uv.y) - step(0.245, uv.y);\n \twhiteTile += step(0.755, uv.y) - step(0.775, uv.y);\n \n // Black lines\n // Vertical\n blackTile += step(0.10, uv.x) - step(0.11, uv.x);\n blackTile += step(0.12, uv.x) - step(0.13, uv.x);\n blackTile += step(0.14, uv.x) - step(0.15, uv.x);\n blackTile += step(0.18, uv.x) - step(0.19, uv.x);\n blackTile += step(0.2, uv.x) - step(0.21, uv.x);\n blackTile += step(0.29, uv.x) - step(0.3, uv.x);\n blackTile += step(0.31, uv.x) - step(0.32, uv.x);\n blackTile += step(0.35, uv.x) - step(0.36, uv.x);\n blackTile += step(0.37, uv.x) - step(0.38, uv.x);\n blackTile += step(0.39, uv.x) - step(0.4, uv.x);\n blackTile += step(0.59, uv.x) - step(0.6, uv.x);\n blackTile += step(0.61, uv.x) - step(0.62, uv.x);\n blackTile += step(0.63, uv.x) - step(0.64, uv.x);\n blackTile += step(0.68, uv.x) - step(0.69, uv.x);\n blackTile += step(0.7, uv.x) - step(0.71, uv.x);\n blackTile += step(0.77, uv.x) - step(0.78, uv.x);\n blackTile += step(0.8, uv.x) - step(0.81, uv.x);\n blackTile += step(0.85, uv.x) - step(0.86, uv.x);\n blackTile += step(0.87, uv.x) - step(0.88, uv.x);\n blackTile += step(0.89, uv.x) - step(0.9, uv.x);\n // Horizontal\n blackTile += step(0.07, uv.y) - step(0.08, uv.y);\n blackTile += step(0.05, uv.y) - step(0.06, uv.y);\n blackTile += step(0.39, uv.y) - step(0.4, uv.y);\n blackTile += step(0.41, uv.y) - step(0.42, uv.y);\n blackTile += step(0.59, uv.y) - step(0.6, uv.y);\n blackTile += step(0.61, uv.y) - step(0.62, uv.y);\n blackTile += step(0.90, uv.y) - step(0.91, uv.y);\n blackTile += step(0.92, uv.y) - step(0.93, uv.y);\n \n // Apply\n value = mix(value, tar1Blue, vec3(blueTile * noise(uv* 1000.)));\n value = mix(value, tar1White, vec3(whiteTile * noise(uv * 200.)));\n value = mix(value, tar1Black, vec3(blackTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 8) // Scottish Tartan 2\n {\n vec3 value = tar2BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float orangeTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // Orange lines\n // Vertical\n orangeTile += step(0.0001, uv.x) - step(0.02, uv.x);\n orangeTile += step(0.49, uv.x) - step(0.51, uv.x);\n orangeTile += step(0.04, uv.x) - step(0.05, uv.x);\n orangeTile += step(0.97, uv.x) - step(0.98, uv.x);\n orangeTile += step(0.46, uv.x) - step(0.47, uv.x);\n orangeTile += step(0.53, uv.x) - step(0.54, uv.x);\n // Horizontal\n orangeTile += step(0.220, uv.y) - step(0.245, uv.y);\n \torangeTile += step(0.755, uv.y) - step(0.775, uv.y);\n orangeTile += step(0.200, uv.y) - step(0.210, uv.y);\n orangeTile += step(0.255, uv.y) - step(0.265, uv.y);\n orangeTile += step(0.730, uv.y) - step(0.740, uv.y);\n orangeTile += step(0.79, uv.y) - step(0.8, uv.y);\n \n // Apply\n value = mix(value, tar2Blue, vec3(blueTile * noise(uv* 1200.)));\n value = mix(value, tar2Orange, vec3(orangeTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 9) // Art Installation\n {\n vec2 uv2 = fragCoord.xy/iResolution.xy;\n uv2 -= 0.5;\n uv2.x *= 1.6;\n uv2.y *= 1.9;\n \n float dist = length(uv2);\n \n vec2 fragCo = fragCoord.xy;\n vec2 center = iResolution.xy * 0.5;\n float width = iResolution.x * 0.4;\n float height = iResolution.x * 0.2;\n \n vec3 value = mix(violet, yellow, dist);\n \n vec4 finalVal = vec4(value, 1.0);\n \n vec4 rect = rectangle(fragCo, center, width, height, violet);\n \n fragColor = mix(finalVal,rect,rect.a);\n fragColor = finalVal;\n }\n gl_FragColor = fragColor;\n}",vh="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n// variant of Vorocracks: https://shadertoy.com/view/lsVyRy\n// integrated with cracks here: https://www.shadertoy.com/view/Xd3fRN\n\n#define MM 0\n\n#define VARIANT 1 // 1: amplifies Voronoi cell jittering\n#if VARIANT\n float ofs = .5; // jitter Voronoi centers in -ofs ... 1.+ofs\n#else\n float ofs = 0.;\n#endif\n \n//int FAULT = 1; // 0: crest 1: fault\n\nfloat RATIO = 1., // stone length/width ratio\n /* STONE_slope = .3, // 0. .3 .3 -.3\n STONE_height = 1., // 1. 1. .6 .7\n profile = 1., // z = height + slope * dist ^ prof\n */ \n CRACK_depth = 3.,\n CRACK_zebra_scale = 1., // fractal shape of the fault zebra\n CRACK_zebra_amp = .67,\n CRACK_profile = 1., // fault vertical shape 1. .2 \n CRACK_slope = 50., // 10. 1.4\n CRACK_width = .0;\n \n\n// std int hash, inspired from https://www.shadertoy.com/view/XlXcW4\nvec3 hash3( uvec3 x ) \n{\n# define scramble x = ( (x>>8U) ^ x.yzx ) * 1103515245U // GLIB-C const\n scramble; scramble; scramble; \n return vec3(x) / float(0xffffffffU) + 1e-30; // <- eps to fix a windows/angle bug\n}\n\n// === Voronoi =====================================================\n// --- Base Voronoi. inspired by https://www.shadertoy.com/view/MslGD8\n\n#define hash22(p) fract( 18.5453 * sin( p * mat2(127.1,311.7,269.5,183.3)) )\n#define disp(p) ( -ofs + (1.+2.*ofs) * hash22(p) )\n\nvec3 voronoi( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), v;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, v = r;\n }\n\n return vec3( sqrt(m), v+u );\n}\n\n// --- Voronoi distance to borders. inspired by https://www.shadertoy.com/view/ldl3W8\nvec3 voronoiB( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), C, P;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, C = p-iu, P = r;\n }\n\n m = 1e9;\n \n for( int k=0; k < 25; k++ ) {\n vec2 p = iu+C + vec2(k%5-2,k/5-2),\n\t\t o = disp(p),\n r = p-u + o;\n\n if( dot(P-r,P-r)>1e-5 )\n m = min( m, .5*dot( (P+r), normalize(r-P) ) );\n }\n\n return vec3( m, P+u );\n}\n\n// === pseudo Perlin noise =============================================\n#define rot(a) mat2(cos(a),-sin(a),sin(a),cos(a))\nint MOD = 1; // type of Perlin noise\n \n// --- 2D\n#define hash21(p) fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453123)\nfloat noise2(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix(hash21(i+vec2(0,0)),hash21(i+vec2(1,0)),f.x),\n mix(hash21(i+vec2(0,1)),hash21(i+vec2(1,1)),f.x), f.y);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm2(vec2 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise2(p);\n\n return v;\n}\n#define noise22(p) vec2(noise2(p),noise2(p+17.7))\nvec2 fbm22(vec2 p) {\n vec2 v = vec2(0);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise22(p);\n\n return v;\n}\nvec2 mfbm22(vec2 p) { // multifractal fbm \n vec2 v = vec2(1);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n //v *= 1.+noise22(p);\n v += v * a * noise22(p);\n\n return v-1.;\n}\n\n/*\n// --- 3D \n#define hash31(p) fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123)\nfloat noise3(vec3 p) {\n vec3 i = floor(p);\n vec3 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix( mix(hash31(i+vec3(0,0,0)),hash31(i+vec3(1,0,0)),f.x),\n mix(hash31(i+vec3(0,1,0)),hash31(i+vec3(1,1,0)),f.x), f.y), \n mix( mix(hash31(i+vec3(0,0,1)),hash31(i+vec3(1,0,1)),f.x),\n mix(hash31(i+vec3(0,1,1)),hash31(i+vec3(1,1,1)),f.x), f.y), f.z);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm3(vec3 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p.xy *= R, p.yz *= R,\n v += a * noise3(p);\n\n return v;\n}\n*/\n \n// ======================================================\n\nvoid main()\n{\n vec4 O;\n vec2 U = vertexUv.xy * iResolution.yy;\n U *= 4./iResolution.y;\n U.x += iTime; // for demo\n // O = vec4( 1.-voronoiB(U).x,voronoi(U).x, 0,0 ); // for tests\n vec2 I = floor(U/2.); \n bool vert = mod(I.x+I.y,2.)==0.; //if (vert) U = U.yx;\n vec3 H0;\n O-=O;\n\n for(float i=0.; i{this.parse(e,t,i)}),n,i)}parse(e,t,n){this.decodeDracoFile(e,t,null,null,Z).catch(n)}decodeDracoFile(e,t,n,i,r=K){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){const n=JSON.stringify(t);if(yh.has(e)){const t=yh.get(e);if(t.key===n)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 i;const r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((n=>(i=n,new Promise(((n,a)=>{i._callbacks[r]={resolve:n,reject:a},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),yh.set(e,{key:n,promise:s}),s}_createGeometry(e){const t=new Fn;e.index&&t.setIndex(new En(e.index.array,1));for(let n=0;n{n.load(e,t,void 0,i)}))}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 n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=wh.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.lengtht._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_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{const t=e.draco,s=new t.Decoder;try{const e=function(e,t,i,r){const a=r.attributeIDs,s=r.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 a){const l=self[s[i]];let c,d;if(r.useUniqueIDs)d=a[i],c=t.GetAttributeByUniqueId(o,d);else{if(d=t.GetAttributeId(o,e[a[i]]),-1===d)continue;c=t.GetAttribute(o,d)}const u=n(e,t,o,i,l,c);"color"===i&&(u.vertexColorSpace=r.vertexColorSpace),h.attributes.push(u)}return c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const i=3*n.num_faces(),r=4*i,a=e._malloc(r);t.GetTrianglesUInt32Array(n,r,a);const s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,o)),e.destroy(o),h}(t,s,new Int8Array(i),a),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}}))}}}function bh(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e=2.0 are supported.")));const l=new pd(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(a),l.setPlugins(s),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function Th(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Eh={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_MATERIALS_BUMP:"EXT_materials_bump",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 Ah{constructor(e){this.parser=e,this.name=Eh.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class kh{constructor(e){this.parser=e,this.name=Eh.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.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 Hh{constructor(e){this.parser=e,this.name=Eh.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.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 Vh{constructor(e){this.name=Eh.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=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 i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(t),a,s,o,e.mode,e.filter),t}))}))}return null}}class Gh{constructor(e){this.name=Eh.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==Qh.TRIANGLES&&e.mode!==Qh.TRIANGLE_STRIP&&e.mode!==Qh.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,a=[],s={};for(const e in r)a.push(this.parser.getDependency("accessor",r[e]).then((t=>(s[e]=t,s[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new At,n=new Je,a=new Ke,o=new Je(1,1,1),l=new Ls(e.geometry,e.material,i);for(let e=0;e-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Qo(this.options.manager):this.textureLoader=new gl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Zo(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 n=this,i=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};return sd(r,a,i),od(a,i),Promise.all(n._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||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,h[e*a+1]),a>=3&&p.setZ(t,h[e*a+2]),a>=4&&p.setW(t,h[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);const n=(r.samplers||{})[a.sampler]||{};return t.magFilter=ed[n.magFilter]||E,t.minFilter=ed[n.minFilter]||A,t.wrapS=td[n.wrapS]||y,t.wrapT=td[n.wrapT]||y,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=n.images[e],a=self.URL||self.webkitURL;let s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new We(e);t.needsUpdate=!0,n(t)}),t.load(ml.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){var t;return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[Eh.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Eh.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(a);a=r.extensions[Eh.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Gs,xn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Ds,xn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||a){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return yo}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const s={},o=[];if((r.extensions||{})[Eh.KHR_MATERIALS_UNLIT]){const e=i[Eh.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),o.push(e.extendParams(s,r,t))}else{const n=r.pbrMetallicRoughness||{};if(s.color=new gn(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],K),s.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(s,"map",n.baseColorTexture,Z)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(s,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===r.doubleSided&&(s.side=2);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,"MASK"===l&&(s.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&a!==yn&&(o.push(t.assignTexture(s,"normalMap",r.normalTexture)),s.normalScale=new be(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==r.occlusionTexture&&a!==yn&&(o.push(t.assignTexture(s,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(s.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&a!==yn){const e=r.emissiveFactor;s.emissive=(new gn).setRGB(e[0],e[1],e[2],K)}return void 0!==r.emissiveTexture&&a!==yn&&o.push(t.assignTexture(s,"emissiveMap",r.emissiveTexture,Z)),Promise.all(o).then((function(){const n=new a(s);return r.name&&(n.name=r.name),od(n,r),t.associations.set(n,{materials:e}),r.extensions&&sd(i,n,r),n}))}createUniqueName(e){const t=bl.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Eh.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return fd(n,e,t)}))}const a=[];for(let n=0,s=e.length;n0&&ld(d,r),d.name=t.createUniqueName(r.name||"mesh_"+e),od(d,r),h.extensions&&sd(i,d,h),t.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n1?new Ja:1===t.length?t[0]:new Qt,s!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of i.associations)(e instanceof xn||e instanceof We)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const a=[],s=e.name?e.name:e.uuid,o=[];let l;switch(rd[r.path]===rd.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(s),rd[r.path]){case rd.weights:l=Uo;break;case rd.rotation:l=Bo;break;case rd.position:case rd.scale:l=ko;break;default:l=1===n.itemSize?Uo:ko}const c=void 0!==i.interpolation?ad[i.interpolation]:j,h=this._getArrayFromAccessor(n);for(let e=0,n=o.length;eMath.PI&&(_-=m),w<-Math.PI?w+=m:w>Math.PI&&(w-=m),s.theta=_<=w?Math.max(_,Math.min(w,s.theta)):s.theta>(_+w)/2?Math.max(_,s.theta):Math.min(w,s.theta)),s.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,s.phi)),s.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(c,n.dampingFactor):n.target.add(c),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&S||n.object.isOrthographicCamera?s.radius=I(s.radius):s.radius=I(s.radius*l),t.setFromSpherical(s),t.applyQuaternion(d),v.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(o.theta*=1-n.dampingFactor,o.phi*=1-n.dampingFactor,c.multiplyScalar(1-n.dampingFactor)):(o.set(0,0,0),c.set(0,0,0));let b=!1;if(n.zoomToCursor&&S){let i=null;if(n.object.isPerspectiveCamera){const e=t.length();i=I(e*l);const r=e-i;n.object.position.addScaledVector(x,r),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const e=new Je(y.x,y.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),b=!0;const r=new Je(y.x,y.y,0);r.unproject(n.object),n.object.position.sub(r).add(e),n.object.updateMatrixWorld(),i=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==i&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(i).add(n.object.position):(_d.origin.copy(n.object.position),_d.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(_d.direction))a||8*(1-p.dot(n.object.quaternion))>a||f.distanceToSquared(n.target)>0)&&(n.dispatchEvent(md),u.copy(n.object.position),p.copy(n.object.quaternion),f.copy(n.target),!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",Y),n.domElement.removeEventListener("pointerdown",V),n.domElement.removeEventListener("pointercancel",W),n.domElement.removeEventListener("wheel",j),n.domElement.removeEventListener("pointermove",G),n.domElement.removeEventListener("pointerup",W),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",X),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let r=i.NONE;const a=1e-6,s=new Al,o=new Al;let l=1;const c=new Je,h=new be,d=new be,u=new be,p=new be,f=new be,m=new be,g=new be,v=new be,_=new be,x=new Je,y=new be;let S=!1;const w=[],b={};function M(){return Math.pow(.95,n.zoomSpeed)}function T(e){o.theta-=e}function E(e){o.phi-=e}const A=function(){const e=new Je;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),c.add(e)}}(),R=function(){const e=new Je;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),c.add(e)}}(),C=function(){const e=new Je;return function(t,i){const r=n.domElement;if(n.object.isPerspectiveCamera){const a=n.object.position;e.copy(a).sub(n.target);let s=e.length();s*=Math.tan(n.object.fov/2*Math.PI/180),A(2*t*s/r.clientHeight,n.object.matrix),R(2*i*s/r.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(A(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),R(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function P(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function L(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function D(e){if(!n.zoomToCursor)return;S=!0;const t=n.domElement.getBoundingClientRect(),i=e.clientX-t.left,r=e.clientY-t.top,a=t.width,s=t.height;y.x=i/a*2-1,y.y=-r/s*2+1,x.set(y.x,y.y,1).unproject(n.object).sub(n.object.position).normalize()}function I(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function N(e){h.set(e.clientX,e.clientY)}function O(e){p.set(e.clientX,e.clientY)}function U(){if(1===w.length)h.set(w[0].pageX,w[0].pageY);else{const e=.5*(w[0].pageX+w[1].pageX),t=.5*(w[0].pageY+w[1].pageY);h.set(e,t)}}function F(){if(1===w.length)p.set(w[0].pageX,w[0].pageY);else{const e=.5*(w[0].pageX+w[1].pageX),t=.5*(w[0].pageY+w[1].pageY);p.set(e,t)}}function B(){const e=w[0].pageX-w[1].pageX,t=w[0].pageY-w[1].pageY,n=Math.sqrt(e*e+t*t);g.set(0,n)}function z(e){if(1==w.length)d.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);d.set(n,i)}u.subVectors(d,h).multiplyScalar(n.rotateSpeed);const t=n.domElement;T(2*Math.PI*u.x/t.clientHeight),E(2*Math.PI*u.y/t.clientHeight),h.copy(d)}function k(e){if(1===w.length)f.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);f.set(n,i)}m.subVectors(f,p).multiplyScalar(n.panSpeed),C(m.x,m.y),p.copy(f)}function H(e){const t=Z(e),i=e.pageX-t.x,r=e.pageY-t.y,a=Math.sqrt(i*i+r*r);v.set(0,a),_.set(0,Math.pow(v.y/g.y,n.zoomSpeed)),P(_.y),g.copy(v)}function V(e){!1!==n.enabled&&(0===w.length&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener("pointermove",G),n.domElement.addEventListener("pointerup",W)),function(e){w.push(e)}(e),"touch"===e.pointerType?function(e){switch(q(e),w.length){case 1:switch(n.touches.ONE){case 0:if(!1===n.enableRotate)return;U(),r=i.TOUCH_ROTATE;break;case 1:if(!1===n.enablePan)return;F(),r=i.TOUCH_PAN;break;default:r=i.NONE}break;case 2:switch(n.touches.TWO){case 2:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&B(),n.enablePan&&F(),r=i.TOUCH_DOLLY_PAN;break;case 3:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&B(),n.enableRotate&&U(),r=i.TOUCH_DOLLY_ROTATE;break;default:r=i.NONE}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(gd)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case 1:if(!1===n.enableZoom)return;!function(e){D(e),g.set(e.clientX,e.clientY)}(e),r=i.DOLLY;break;case 0:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;O(e),r=i.PAN}else{if(!1===n.enableRotate)return;N(e),r=i.ROTATE}break;case 2:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;N(e),r=i.ROTATE}else{if(!1===n.enablePan)return;O(e),r=i.PAN}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(gd)}(e))}function G(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(q(e),r){case i.TOUCH_ROTATE:if(!1===n.enableRotate)return;z(e),n.update();break;case i.TOUCH_PAN:if(!1===n.enablePan)return;k(e),n.update();break;case i.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&H(e),n.enablePan&&k(e)}(e),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&H(e),n.enableRotate&&z(e)}(e),n.update();break;default:r=i.NONE}}(e):function(e){switch(r){case i.ROTATE:if(!1===n.enableRotate)return;!function(e){d.set(e.clientX,e.clientY),u.subVectors(d,h).multiplyScalar(n.rotateSpeed);const t=n.domElement;T(2*Math.PI*u.x/t.clientHeight),E(2*Math.PI*u.y/t.clientHeight),h.copy(d),n.update()}(e);break;case i.DOLLY:if(!1===n.enableZoom)return;!function(e){v.set(e.clientX,e.clientY),_.subVectors(v,g),_.y>0?P(M()):_.y<0&&L(M()),g.copy(v),n.update()}(e);break;case i.PAN:if(!1===n.enablePan)return;!function(e){f.set(e.clientX,e.clientY),m.subVectors(f,p).multiplyScalar(n.panSpeed),C(m.x,m.y),p.copy(f),n.update()}(e)}}(e))}function W(e){!function(e){delete b[e.pointerId];for(let t=0;t0&&P(M()),n.update()}(e),n.dispatchEvent(vd))}function X(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?E(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?E(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?T(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?T(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function Y(e){!1!==n.enabled&&e.preventDefault()}function q(e){let t=b[e.pointerId];void 0===t&&(t=new be,b[e.pointerId]=t),t.set(e.pageX,e.pageY)}function Z(e){const t=e.pointerId===w[0].pointerId?w[1]:w[0];return b[t.pointerId]}n.domElement.addEventListener("contextmenu",Y),n.domElement.addEventListener("pointerdown",V),n.domElement.addEventListener("pointercancel",W),n.domElement.addEventListener("wheel",j,{passive:!1}),this.update()}}const wd=new Ml,bd=new Je,Md=new Je,Td=new Ke,Ed={X:new Je(1,0,0),Y:new Je(0,1,0),Z:new Je(0,0,1)},Ad={type:"change"},Rd={type:"mouseDown"},Cd={type:"mouseUp",mode:null},Pd={type:"objectChange"};class Ld extends Qt{constructor(e,t){super(),void 0===t&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const n=new Qd;this._gizmo=n,this.add(n);const i=new $d;this._plane=i,this.add(i);const r=this;function a(e,t){let a=t;Object.defineProperty(r,e,{get:function(){return void 0!==a?a:t},set:function(t){a!==t&&(a=t,i[e]=t,n[e]=t,r.dispatchEvent({type:e+"-changed",value:t}),r.dispatchEvent(Ad))}}),r[e]=t,i[e]=t,n[e]=t}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0);const s=new Je,o=new Je,l=new Ke,c=new Ke,h=new Je,d=new Ke,u=new Je,p=new Je,f=new Je,m=new Je;a("worldPosition",s),a("worldPositionStart",o),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",h),a("cameraQuaternion",d),a("pointStart",u),a("pointEnd",p),a("rotationAxis",f),a("rotationAngle",0),a("eye",m),this._offset=new Je,this._startNorm=new Je,this._endNorm=new Je,this._cameraScale=new Je,this._parentPosition=new Je,this._parentQuaternion=new Ke,this._parentQuaternionInv=new Ke,this._parentScale=new Je,this._worldScaleStart=new Je,this._worldQuaternionInv=new Ke,this._worldScale=new Je,this._positionStart=new Je,this._quaternionStart=new Ke,this._scaleStart=new Je,this._getPointer=Dd.bind(this),this._onPointerDown=Nd.bind(this),this._onPointerHover=Id.bind(this),this._onPointerMove=Od.bind(this),this._onPointerUp=Ud.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(void 0===this.object||!0===this.dragging)return;wd.setFromCamera(e,this.camera);const t=Fd(this._gizmo.picker[this.mode],wd);this.axis=t?t.object.name:null}pointerDown(e){if(void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis){wd.setFromCamera(e,this.camera);const t=Fd(this._plane,wd,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Rd.mode=this.mode,this.dispatchEvent(Rd)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(r="world"),void 0===i||null===t||!1===this.dragging||-1!==e.button)return;wd.setFromCamera(e,this.camera);const a=Fd(this._plane,wd,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(Td.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(bd.setFromMatrixPosition(i.parent.matrixWorld)),-1!==t.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(bd.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===n){if(-1!==t.search("XYZ")){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),Md.set(e,e,e)}else bd.copy(this.pointStart),Md.copy(this.pointEnd),bd.applyQuaternion(this._worldQuaternionInv),Md.applyQuaternion(this._worldQuaternionInv),Md.divide(bd),-1===t.search("X")&&(Md.x=1),-1===t.search("Y")&&(Md.y=1),-1===t.search("Z")&&(Md.z=1);i.scale.copy(this._scaleStart).multiply(Md),this.scaleSnap&&(-1!==t.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const e=20/this.worldPosition.distanceTo(bd.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(bd.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(Ed[t]),bd.copy(Ed[t]),"local"===r&&bd.applyQuaternion(this.worldQuaternion),bd.cross(this.eye),0===bd.length()?n=!0:this.rotationAngle=this._offset.dot(bd.normalize())*e),("E"===t||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==t&&"XYZE"!==t?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Td.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Td.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Ad),this.dispatchEvent(Pd)}}pointerUp(e){0===e.button&&(this.dragging&&null!==this.axis&&(Cd.mode=this.mode,this.dispatchEvent(Cd)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Ad),this.dispatchEvent(Pd),this.pointStart.copy(this.pointEnd))}getRaycaster(){return wd}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Dd(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{const t=this.domElement.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*2-1,y:-(e.clientY-t.top)/t.height*2+1,button:e.button}}}function Id(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}function Nd(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function Od(e){this.enabled&&this.pointerMove(this._getPointer(e))}function Ud(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}function Fd(e,t,n){const i=t.intersectObject(e,!0);for(let e=0;ee&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(zd.copy(Yd).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(zd.copy(qd).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(zd.copy(qd).applyQuaternion(t).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(Td.setFromEuler(Bd.set(0,0,Math.PI/2)),i.quaternion.copy(t).multiply(Td),Math.abs(zd.copy(Yd).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(Td.setFromEuler(Bd.set(0,Math.PI/2,0)),i.quaternion.copy(t).multiply(Td),Math.abs(zd.copy(qd).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(Td.setFromEuler(Bd.set(0,Math.PI/2,0)),zd.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Hd.lookAt(kd,zd,Yd)),i.quaternion.multiply(Td),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),bd.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),bd.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(bd),i.visible=this.dragging):(i.quaternion.copy(t),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(e)}}class $d extends ti{constructor(){super(new Mi(1e5,1e5,2,2),new yn({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),Zd.copy(Xd).applyQuaternion("local"===t?this.worldQuaternion:Gd),Kd.copy(Yd).applyQuaternion("local"===t?this.worldQuaternion:Gd),Jd.copy(qd).applyQuaternion("local"===t?this.worldQuaternion:Gd),zd.copy(Kd),this.mode){case"translate":case"scale":switch(this.axis){case"X":zd.copy(this.eye).cross(Zd),Wd.copy(Zd).cross(zd);break;case"Y":zd.copy(this.eye).cross(Kd),Wd.copy(Kd).cross(zd);break;case"Z":zd.copy(this.eye).cross(Jd),Wd.copy(Jd).cross(zd);break;case"XY":Wd.copy(Jd);break;case"YZ":Wd.copy(Zd);break;case"XZ":zd.copy(Jd),Wd.copy(Kd);break;case"XYZ":case"E":Wd.set(0,0,0)}break;default:Wd.set(0,0,0)}0===Wd.length()?this.quaternion.copy(this.cameraQuaternion):(jd.lookAt(bd.set(0,0,0),Wd,zd),this.quaternion.setFromRotationMatrix(jd)),super.updateMatrixWorld(e)}}class eu{constructor(e,t,n){this.renderer=e,this.canvas=n||this.renderer.domElement,this.camera=t,this.orbitControls=new Sd(t,this.canvas)}addTransformControl(e,t){const n=new Ld(this.camera,this.canvas);return n.addEventListener("dragging-changed",(e=>{this.orbitControls.enabled=!e.value})),n.attach(e),t.add(n),n}update(){this.orbitControls.update()}}class tu{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse((e=>{var t,n,i;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(i=this._cache)||void 0===i||i.addObject(e)})),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class nu{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach((e=>{e.dispose()}))}registerCache(e,t){this._cacheMap.set(e,new tu(t))}clearCache(){this._cacheMap.forEach((e=>{e.clear()}))}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const i=this._cacheMap.get(e);i&&(i.update(t),i.onBeforeRender()),n(),i&&i.onAfterRender()}}class iu{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=!1}))}onAfterRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=e}))}}class ru{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof yo&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!1}))}onAfterRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!0}))}}class au{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach(((e,t)=>{t instanceof ti&&t.material!==e.originalObjectData.material&&t.material!==e.updateObjectData.material&&(e.originalObjectData.material=t.material),this._updateObject(t,e.updateObjectData)}))}onAfterRender(){this._objectCache.forEach(((e,t)=>{this._updateObject(t,e.originalObjectData)}))}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof ti?e.receiveShadow:void 0,material:e instanceof ti?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof ti&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof ti&&void 0!==t.material&&(e.material=t.material)}}class su extends li{constructor(e){var t;super({defines:Object.assign(Object.assign(Object.assign({},su._normalAndDepthShader.defines),{FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0})),uniforms:oi.clone(su._normalAndDepthShader.uniforms),vertexShader:su._normalAndDepthShader.vertexShader,fragmentShader:su._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}su._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};class ou{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}updateGBufferRenderMaterial(e){var t;return this._gBufferRenderMaterial=null!==(t=this._gBufferRenderMaterial)&&void 0!==t?t:this.floatRgbNormalAlphaDepth?new su({blending:0,floatBufferType:!0,linearDepth:!1}):new bo({blending:0}),this._gBufferRenderMaterial instanceof su&&this._gBufferRenderMaterial.update({camera:e}),this._gBufferRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatRgbNormalAlphaDepth)this._depthNormalRenderTarget=new Ye(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:L,samples:this._samples});else{const e=new ar(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=U,e.type=I,this._depthNormalRenderTarget=new Ye(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new Ye(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:L,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,i,r,a,s,o,l,c,h,d;this.floatRgbNormalAlphaDepth=!1,this.linearDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.floatRgbNormalAlphaDepth=null!==(i=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==i&&i,this._renderCacheManager=e,this._renderCacheManager&&(this._gBufferMaterialCache=new lu,this._renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(r=null==t?void 0:t.depthNormalScale)&&void 0!==r?r:1},this._targetMinificationTextureFilter=null!==(a=null==t?void 0:t.textureMinificationFilter)&&void 0!==a?a:b,this._targetMagnificationTextureFilter=null!==(s=null==t?void 0:t.textureMagnificationFilter)&&void 0!==s?s:b,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(c=null==t?void 0:t.samples)&&void 0!==c?c:0,this._shared=null!==(h=null==t?void 0:t.shared)&&void 0!==h&&h,this._renderPass=null!==(d=null==t?void 0:t.renderPass)&&void 0!==d?d:new sc}dispose(){var e,t;null===(e=this._gBufferRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}render(e,t,n){this._shared&&!this.needsUpdate||(this.needsUpdate=!1,this._renderCacheManager?this._renderCacheManager.render(this,t,(()=>{this._renderGBuffer(e,t,n)})):this._renderGBuffer(e,t,n),this.floatRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget))}_renderGBuffer(e,t,n){this._renderPass.renderWithOverrideMaterial(e,t,n,this.updateGBufferRenderMaterial(n),this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new jl),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:0,colorTransform:Ul,colorBase:kl,multiplyChannels:0,uvTransform:Hl}),this.separateDeptRenderTarget)}}class lu extends au{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!0}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof xn&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof So&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class cu extends ti{constructor(e,t){const n=new yn({transparent:!0,depthWrite:!1});cu.alphaMap&&n.color.set(0),n.polygonOffset=!0,super(new Mi(1,1,10,10),n),this.name="ShadowGroundPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.setVisibilityLayers(e)}setVisibilityLayers(e){e?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;t.map=e,cu.alphaMap&&(t.alphaMap=e),t.needsUpdate=!0}updateMaterial(e){const t=this.material;e.opacity&&t.opacity!==e.opacity&&(t.opacity=e.opacity),e.polygonOffset&&t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset),t.needsUpdate=!0}}cu.alphaMap=!1;class hu{get shadowGroundPlane(){var e;let t=this._sharedShadowGroundPlane;return t||(null!==(e=this._shadowGroundPlane)&&void 0!==e||(this._shadowGroundPlane=new cu(this.renderTarget.texture,this.parameters)),t=this._shadowGroundPlane),t.parent!==this._groundGroup&&this._groundGroup.add(t),t}constructor(e,t,n){var i;this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=t,this.shadowMapSize=null!==(i=n.shadowMapSize)&&void 0!==i?i:2048,this.parameters=this._getDefaultParameters(n),this._groundShadowFar=this.parameters.cameraFar,this._renderer=e,this._renderCacheManager=null==n?void 0:n.renderCacheManager,this._renderCacheManager&&this._renderCacheManager.registerCache(this,new iu((e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name)))),this.renderTarget=new Ye(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new Ye(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this._sharedShadowGroundPlane=null==n?void 0:n.sharedShadowGroundPlane,this.shadowGroundPlane.setShadowMap(this.renderTarget.texture),this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera=new du,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new Wa,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",cu.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=2,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new oc(Xl,n),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return Object.assign({enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:40,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0},e)}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFarthis.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibilityLayers(e){this.shadowGroundPlane.setVisibilityLayers(e)}render(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,e),!this.parameters.enabled)return;if(this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(e),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this._renderCacheManager?this._renderCacheManager.render(this,e,(()=>{this._renderer.render(e,this._groundContactCamera)})):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}hu.addTestMesh=!1;class du extends Oi{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,i,r;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new Pl(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(i=this.cameraHelper)||void 0===i?void 0:i.parent)&&(null===(r=this.cameraHelper)||void 0===r||r.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}const uu={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},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 float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},pu={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new be(1/1024,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\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t\t//----------------------------------------------------------------------------------\n\t\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t\t// SDK Version: v3.00\n\t\t// Email: gameworks@nvidia.com\n\t\t// Site: http://developer.nvidia.com/\n\t\t//\n\t\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t\t//\n\t\t// Redistribution and use in source and binary forms, with or without\n\t\t// modification, are permitted provided that the following conditions\n\t\t// are met:\n\t\t// * Redistributions of source code must retain the above copyright\n\t\t// notice, this list of conditions and the following disclaimer.\n\t\t// * Redistributions in binary form must reproduce the above copyright\n\t\t// notice, this list of conditions and the following disclaimer in the\n\t\t// documentation and/or other materials provided with the distribution.\n\t\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t\t// contributors may be used to endorse or promote products derived\n\t\t// from this software without specific prior written permission.\n\t\t//\n\t\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t\t//\n\t\t//----------------------------------------------------------------------------------\n\n\t\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t\t#endif\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t\t/*--------------------------------------------------------------------------*/\n\n\t\t#define NUM_SAMPLES 5\n\n\t\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\t\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t\t}\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t\t============================================================================*/\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t// locate the edge\n\t\t\t\tvec2 dirToEdge;\n\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t// . 2 . . 1 .\n\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t// . 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 H\n\n\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t// V 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 .\n\n\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t// 1 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t// do a simple blur\n\t\t\t\t\treturn mix(\n\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t.4\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\titerationsUsed = i;\n\n\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\tif(!doneN) {\n\t\t\t\t\tnDist += increment;\n\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t}\n\n\t\t\t\tif(!doneP) {\n\t\t\t\t\tpDist += increment;\n\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t}\n\n\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\trgbaM,\n\t\t\t\trgbaN,\n\t\t\t\tdist * .5\n\t\t\t);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\tvUv,\n\t\t\t\ttDiffuse,\n\t\t\t\tresolution,\n\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t\t}\n\t"};class fu extends ql{constructor(e,t,n,i,r){var a;super(),this.patternTexture=null,this._gBufferRenderTarget=null==r?void 0:r.gBufferRenderTarget,this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new gn(1,1,1),this.hiddenEdgeColor=new gn(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==r?void 0:r.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==r?void 0:r.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==e?new be(e.x,e.y):new be(256,256);const s=Math.round(this.resolution.x/this.downSampleRatio),o=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Ye(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this._gBufferRenderTarget||(this.depthMaterial=new Wa,this.depthMaterial.side=2,this.depthMaterial.depthPacking=3201,this.depthMaterial.blending=0),this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this._gBufferRenderTarget||(this.renderTargetDepthBuffer=new Ye(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new li(pu),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new Ye(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new Ye(s,o),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Ye(s,o),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Ye(Math.round(s/2),Math.round(o/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Ye(s,o),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Ye(Math.round(s/2),Math.round(o/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(s,o),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(s/2),Math.round(o/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const l=uu;this.copyUniforms=oi.clone(l.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new li({uniforms:this.copyUniforms,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new gn,this.oldClearAlpha=1,this.fsQuad=new Jl(void 0),this.tempPulseColor1=new gn,this.tempPulseColor2=new gn,this.textureMatrix=new At}dispose(){var e,t,n,i;this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),null===(t=this.renderTargetDepthBuffer)||void 0===t||t.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),null===(n=this.depthMaterial)||void 0===n||n.dispose(),this.prepareMaskMaterial.dispose(),null===(i=this.fxaaRenderMaterial)||void 0===i||i.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,i,r;this.renderTargetMaskBuffer.setSize(e,t),null===(n=this.renderTargetDepthBuffer)||void 0===n||n.setSize(e,t);let a=Math.round(e/this.downSampleRatio),s=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(a,s),this.renderTargetBlurBuffer1.setSize(a,s),this.renderTargetEdgeBuffer1.setSize(a,s),this.separableBlurMaterial1.uniforms.texSize.value.set(a,s),a=Math.round(a/2),s=Math.round(s/2),this.renderTargetBlurBuffer2.setSize(a,s),this.renderTargetEdgeBuffer2.setSize(a,s),this.separableBlurMaterial2.uniforms.texSize.value.set(a,s),null===(i=this.fxaaRenderMaterial)||void 0===i||i.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(r=this.renderTargetFxaaBuffer)||void 0===r||r.setSize(e,t)}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;function n(n){n.isMesh&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}this.selectedObjects.forEach((e=>e.traverse(n)))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];function i(e){e.isMesh&&n.push(e)}this.selectedObjects.forEach((e=>e.traverse(i))),this.renderScene.traverse((function(i){if(i.isMesh||i.isSprite){if(!1===n.some((e=>e.id===i.id))){const n=i.visible;!1!==e&&!0!==t.get(i)||(i.visible=e),t.set(i,n)}}else(i.isPoints||i.isLine)&&(!0===e?i.visible=t.get(i):(t.set(i,i.visible),i.visible=e))}))}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,r){var a,s;if(this.selectedObjects.length>0){null===(a=this._gBufferRenderTarget)||void 0===a||a.render(e,this.renderScene,this.renderCamera),e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const i=this.renderScene.background;this.renderScene.background=null,this.renderTargetDepthBuffer&&this.depthMaterial&&(this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera)),this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this._gBufferRenderTarget?this.prepareMaskMaterial.uniforms.depthTexture.value=this._gBufferRenderTarget.textureWithDepthValue:this.prepareMaskMaterial.uniforms.depthTexture.value=null===(s=this.renderTargetDepthBuffer)||void 0===s?void 0:s.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=i;let o=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),o=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=o.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=fu.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=fu.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=fu.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=fu.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=o.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}_getPrepareMaskMaterial(e){return new li({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new be(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include \n\t\t\t\t#include \n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new li({uniforms:{maskTexture:{value:null},texSize:{value:new be(.5,.5)},visibleEdgeColor:{value:new Je(1,1,1)},hiddenEdgeColor:{value:new Je(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new li({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new be(.5,.5)},direction:{value:new be(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new li({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}fu.BlurDirectionX=new be(1,0),fu.BlurDirectionY=new be(0,1);class mu{get isOutlinePassActivated(){return this.outlinePassActivated}constructor(e,t,n,i){this._width=0,this._height=0,this._effectComposer=null,this.outlinePass=null,this.outlinePassActivated=!1,this._effectComposer=e,this._gBufferRenderTarget=null==i?void 0:i.gBufferRenderTarget,this._width=t,this._height=n,this.parameters=Object.assign({enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215},i)}dispose(){var e;null===(e=this.outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this.outlinePass)||void 0===n||n.setSize(e,t)}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const i=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!i&&this.outlinePassActivated||(!i&&this.outlinePass||(this.outlinePass=new fu(new be(this._width,this._height),e,t,[],{downSampleRatio:2,edgeDetectionFxaa:!0,gBufferRenderTarget:this._gBufferRenderTarget})),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}class gu extends Bs{constructor(e,t){const n=new Fn;n.setAttribute("position",new Cn([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new Ds({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Fn;i.setAttribute("position",new Cn([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new ti(i,new yn({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class vu extends Mo{constructor(e){super(e),this.onBeforeCompile=this._onBeforeCompile}static setShadowParameters(e,t,n,i,r,a,s){this._enableGroundBoundary=e,vu._distributionProperties.set(t,n,i,r),vu._shadowFadeOut.set(a,s)}static setBoundingBox(e){vu._sceneBoxMin.copy(e.min),vu._sceneBoxMax.copy(e.max)}_onBeforeCompile(e,t){e.vertexShader=_u,e.fragmentShader=xu,e.defines=Object.assign(Object.assign(Object.assign({},e.defines),{DYNAMIC_SHADOW_RADIUS:"",GROUND_BOUNDARY:vu._enableGroundBoundary?1:0}));const n=e.uniforms;n&&(n.distributionProperties={value:vu._distributionProperties},n.shadowFadeOut={value:vu._shadowFadeOut},n.sceneBoxMin={value:vu._sceneBoxMin},n.sceneBoxMax={value:vu._sceneBoxMax})}}vu._enableGroundBoundary=!1,vu._shadowFadeOut=new be(.1,20),vu._sceneBoxMin=new Je(-1,-1,-1),vu._sceneBoxMax=new Je(1,1,1),vu._distributionProperties=new je(1,1,1,1);const _u="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n #include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vWorldPosition = worldPosition.xyz;\n#else\n vWorldPosition = (modelMatrix * vec4(transformed, 1.)).xyz;\n#endif\n}\n",xu="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n #define fadeOutDistance shadowFadeOut.x\n #define fadeOutBlur shadowFadeOut.y\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n#define directionalDependency distributionProperties.x\n#define directionalExponent distributionProperties.y\n#define groundBoundary distributionProperties.z\n#define groundMapScale distributionProperties.w\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvec2 getShadowDynamicScale() {\n vec2 dynamicScale = vec2(0.0, 1.0);\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (fadeOutDistance > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n float shadowBase = clamp(boxDistance / fadeOutDistance, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n float dynamicRadius = shadowRadius;\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && fadeOutDistance > 0.0) {\n //float shadowDepth = unpackRGBAToDepth(texture2D(shadowMap, shadowCoord.xy));\n //float delta = shadowDepth - shadowCoord.z;\n //float fadeOutStart = delta / fadeOutDistance;\n //dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, max(shadowScale.x, fadeOutScale));\n dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, shadowScale.x);\n }\n#endif\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n vec2 dynamicScale = getShadowDynamicScale();\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n IncidentLight directLight;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float groundShadowFactor = 1.;\n float shadowFactor;\n float dynamicRadius;\n float dotNL;\n\n #pragma unroll_loop_start\n for ( int i = 0 ; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( GROUND_BOUNDARY == 1 && UNROLLED_LOOP_INDEX == 0 )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = fadeOutDistance * groundMapScale;\n groundShadowFactor = groundDistance < 0.5 ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0; \n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightSum += directLight.color;\n incidentShadowLight += directLight.color * mix(1.0, shadowFactor, pow(clamp(dotNL, 0.0, 1.0), directionalExponent));\n \n #endif\n }\n #pragma unroll_loop_end\n\n directionDependentShadowLight = incidentShadowLight / ( incidentLightSum + 1. - step(0., incidentLightSum) );\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(directionalDependency, 1.0 - groundDistance));\n #if GROUND_BOUNDARY == 1\n float groundWeight = 1. - groundShadowFactor + groundDistance - (1. - groundShadowFactor) * groundDistance;\n outgoingLight = mix(vec3(1.), outgoingLight, mix(dynamicScale.y, groundWeight, groundBoundary));\n #else\n outgoingLight = mix(vec3(1.), outgoingLight, dynamicScale.y);\n #endif\n\n\t#include \n\t#include \n}\n";var yu;!function(e){e[e.DirectionalLightShadow=0]="DirectionalLightShadow",e[e.SpotLightShadow=1]="SpotLightShadow"}(yu||(yu={}));const Su={alwaysUpdate:!1,enableShadowMap:!0,enableGroundBoundary:!0,layers:null,shadowLightSourceType:yu.DirectionalLightShadow,maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.1,fadeOutBlur:5};class wu{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var i,r;this.needsUpdate=!1,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new Au,this._shadowLightSources=[],this._shadowScale=1,this._groundMapScale=1,this._renderPass=new sc,this._cameraUpdate=new rc,this._renderCacheManager=e,this._viewportSize=new be(t.x,t.y),this._samples=null!==(i=null==n?void 0:n.samples)&&void 0!==i?i:0,this._shadowMapSize=null!==(r=null==n?void 0:n.shadowMapSize)&&void 0!==r?r:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new Eu,this._renderCacheManager.registerCache(this,this._shadowMapPassOverrideMaterialCache);const a=this._samples;this._shadowRenderTarget=new Ye(this._viewportSize.x,this._viewportSize.y,{samples:a,format:F})}_getScreenSpaceShadowMapParameters(e){return Object.assign(Object.assign({},Su),e)}dispose(){this._shadowLightSources.forEach((e=>e.dispose())),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){var n;const i=this._shadowScale;if(this._shadowScale=t,Math.abs(i-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach((t=>t.updateBounds(e))),this._shadowLightSources.length>0){const e=null===(n=this._shadowLightSources[0].getShadowLight().shadow)||void 0===n?void 0:n.camera;e instanceof Oi&&(this._groundMapScale=2*this._shadowMapSize/(Math.abs(e.right-e.left)+Math.abs(e.top-e.bottom)))}else this._groundMapScale=1;this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach((e=>e.forceShadowUpdate())),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map((e=>e.getShadowLight()))}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find((t=>t.getOriginalLight()===e)))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new Cu(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){this._shadowLightSources=this._shadowLightSources.filter((n=>{if(n instanceof Cu){const t=n.getRectAreaLight();if(e.includes(t))return n.updatePositionAndTarget(),!0}return n.removeFrom(t),n.dispose(),!1})),e.forEach((e=>{this._shadowLightSources.find((t=>t instanceof Cu&&t.getRectAreaLight()===e))||this.addRectAreaLight(e,t)})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){this._shadowLightSources=this._shadowLightSources.filter((t=>{t.removeFrom(e),t.dispose()}));const n=1/(t.length>0?Math.max(...t.map((e=>e.maxIntensity))):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach((t=>{t.addTo(e),t.updatePositionAndTarget()})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){const n=new Lu(new Je(0,7,0),{shadowMapSize:this._shadowMapSize});this._shadowLightSources.push(n),e.forEach((e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new Je(e.position.x,e.position.z,e.position.y).multiplyScalar(7),i=new Pu(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(i)}}))}setSize(e,t){this._viewportSize=new be(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach((e=>e.updatePositionAndTarget()))}renderShadowMap(e,t,n){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(n)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const i=t.background,r=t.environment,a=n.layers.mask;t.environment=null,t.background=null,this.parameters.layers&&(n.layers.mask=this.parameters.layers.mask),this._renderSimpleShadowMapFromShadowLightSources(e,t,n),n.layers.mask=a,t.environment=r,t.background=i}_renderSimpleShadowMapFromShadowLightSources(e,t,n){this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.enableGroundBoundary,this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundBoundary,this._groundMapScale,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const i=this._getSortedShadowLightSources();0===i.length?this._renderPass.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(i),this._renderCacheManager.render(this,t,(()=>{this._renderPass.render(e,t,n,this._shadowRenderTarget,16777215,1)})),this._shadowLightSources.forEach((e=>e.finishRenderShadow())))}_getSortedShadowLightSources(){let e=[];return this._shadowLightSources.forEach((t=>e.push(...t.prepareRenderShadow()))),e.sort(((e,t)=>e.light.castShadow&&!t.light.castShadow||e.groundShadow&&!t.groundShadow?-1:!e.light.castShadow&&t.light.castShadow||!e.groundShadow&&t.groundShadow?1:t.intensity-e.intensity)),e}_setShadowLightSourcesIntensity(e){let t=0,n=this.parameters.maximumNumberOfLightSources,i=0;e.forEach((e=>{(n<0||i{var r;!this.parameters.enableGroundBoundary&&e.groundShadow||!(n<0||ie._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale)))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}var bu,Mu,Tu;!function(e){e[e.Default=0]="Default",e[e.Unlit=1]="Unlit",e[e.Emissive=2]="Emissive",e[e.Shadow=3]="Shadow"}(bu||(bu={}));class Eu extends au{set shadowOnGround(e){this._shadowOnGround=e}constructor(){super(),this._boundingBoxSet=!1,this._shadowOnGround=!0,this._shadowObjectMaterial=this._createShadowMaterial(bu.Default),this._unlitMaterial=this._createShadowMaterial(bu.Unlit),this._emissiveMaterial=this._createShadowMaterial(bu.Emissive),this._receiveShadowMaterial=this._createShadowMaterial(bu.Shadow)}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,i,r,a,s){vu.setShadowParameters(e,t,n,i,r,a,s)}setBoundingBox(e){this._boundingBoxSet=!0,vu.setBoundingBox(e)}_createShadowMaterial(e){let t;return t=e===bu.Emissive||e===bu.Unlit?new yn({color:16777215,side:2}):e===bu.Shadow?new xo({side:2}):Eu.useModifiedMaterial?this._createCustomerShadowMaterial():new wo({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:2}),t}_createCustomerShadowMaterial(){return new vu({side:2})}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof Ds||t instanceof yn?this.addToCache(e,{material:this._unlitMaterial}):t instanceof yo?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}Eu.useModifiedMaterial=!0;class Au{constructor(){var e;this.types=new Map([["off",Au._noShadow],["BasicShadowMap",Au._basicShadow],["PCFShadowMap",Au._pcfShadow],["PCFSoftShadowMap",Au._pcfSoftShadow],["VSMShadowMap",Au._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:Au._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:Au._defaultType,!0)}}Au._noShadow={castShadow:!1,type:i,bias:0,normalBias:0,radius:0},Au._basicShadow={castShadow:!0,type:0,bias:-5e-5,normalBias:.005,radius:0},Au._pcfShadow={castShadow:!0,type:i,bias:-5e-5,normalBias:.01,radius:4},Au._pcfSoftShadow={castShadow:!0,type:r,bias:-5e-5,normalBias:.01,radius:1},Au._vcmShadow={castShadow:!0,type:a,bias:1e-4,normalBias:0,radius:15},Au._defaultType=Au._pcfShadow;class Ru{constructor(e,t){var n,i;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(i=null==t?void 0:t.blurSamples)&&void 0!==i?i:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new be(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new Je(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof al){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),i=Math.max(.001,Math.min(-n.min.z,-n.max.z)),r=Math.max(-n.min.z,-n.max.z),a=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),s=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(s,a),i);t.aspect=1,t.near=i,t.far=r,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,i,r;if(this._shadowLightSource instanceof al){const n=t.clone().sub(e),i=n.length();n.normalize();const r=t.clone().sub(n.clone().multiplyScalar(4*i));this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(r),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.lookAt(t);null===(r=this._shadowLightSource.shadow)||void 0===r||r.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class Cu extends Ru{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case yu.DirectionalLightShadow:n=new ul(16777215,1);break;case yu.SpotLightShadow:n=new al(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new gu(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity,groundShadow:!1}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class Pu extends Ru{constructor(e,t,n){const i=new ul(16777215,t);i.position.copy(e),i.lookAt(0,0,0),i.updateMatrix(),i.castShadow=!0,super(i,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity,groundShadow:!1}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}class Lu extends Ru{constructor(e,t){const n=new ul(16777215,1);n.position.copy(e),n.lookAt(0,0,0),n.updateMatrix(),n.castShadow=!0,super(n,t),this._position=e.clone()}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:1,groundShadow:!0}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}!function(e){e[e.INPUT_RGB_NORMAL=0]="INPUT_RGB_NORMAL",e[e.FLOAT_BUFFER_NORMAL=1]="FLOAT_BUFFER_NORMAL",e[e.CONSTANT_Z=2]="CONSTANT_Z"}(Mu||(Mu={})),function(e){e[e.SEPARATE_BUFFER=0]="SEPARATE_BUFFER",e[e.NORMAL_VECTOR_ALPHA=1]="NORMAL_VECTOR_ALPHA"}(Tu||(Tu={}));const Du=(e,t)=>{const n=Iu(e,t);let i="vec4[SAMPLES](";for(let t=0;t{const n=[];for(let i=0;i\n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\t#if DEPTH_BUFFER_ANTIALIAS == 1\n\t\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\t\tivec2 p = ivec2(uv * size);\n\t\t\t\tfloat d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n\t\t\t\tvec2 depth = vec2(d0, 1.0);\n\t\t\t\tfloat d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n\t\t\t\tfloat d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n\t\t\t\tfloat d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n\t\t\t\tfloat d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n\t\t\t\treturn depth.x / depth.y;\n \t#else\n \treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n \t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\t#if NORMAL_VECTOR_ANTIALIAS == 1\n\t\t\t\t\tvec2 uv = screenPosition;\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tfloat c0 = texelFetch(tNormal, p, 0).a;\n\t\t\t\t\tfloat l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t\t\t#elif NORMAL_VECTOR_ANTIALIAS == 2\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tvec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n\t\t\t\t\treturn normalize(normalVector);\n\t\t\t\t#else\n\t\t\t\t\treturn texture2D(tNormal, screenPosition).xyz;\n\t\t\t\t#endif\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(screenPosition);\n\t\t\t#endif\n\t\t }\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\n\t\tfloat sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n\t\t\tvec3 delta = point - pointOnPlane;\n\t\t\tfloat sinV = dot(planeNormal, normalize(delta));\n\t\t\treturn sinV;\n\t\t}\n\n\t\tfloat getFallOff(float delta, float falloffDistance) {\n\t\t\tfloat fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n\t\t\treturn fallOff;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n \t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n\t\t\t#if NV_ALIGNED_SAMPLES == 1\n \t\t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#elif AO_ALGORITHM == 3\n\t\t\tconst int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#else\n\t\t\tconst int DIRECTIONS = SAMPLES;\n\t\t\tconst int STEPS = 1;\n\t\t#endif\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\n\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#elif AO_ALGORITHM == 3\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * 2. * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#else\n\t\t\t\tvec4 sampleDir = sampleKernel[i];\n\t\t\t#endif\n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t#else\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n\t\t\t\t#endif\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleViewOffset;\n\t\t\t#else\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n\t\t\t#endif\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tfloat sceneSampleDist = abs(sampleSceneViewPos.z);\n\t\t\t\t\tfloat sampleDist = abs(sampleViewPos.z);\n\t\t\t\t\t\n\t\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\t\t// HBAO || GTAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\t\t\n\t\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));\t\n\t\t\t\t\t\t}\n\t\t\t\t\t#endif\n\t\t\t\t#elif AO_ALGORITHM == 2\n\t\t\t\t\t// N8AO\n\t\t\t\t\tfloat weight = dot(viewNormal, sampleDir.xyz);\n\t\t\t\t\tfloat occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#elif AO_ALGORITHM == 1\n\t\t\t\t\t// SAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tfloat minResolution = 0.; // ?\n\t\t\t\t\tfloat scaledViewDist = length( viewDelta ) / scale;\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n\t\t\t\t#else\n\t\t\t\t\t// SSAO\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\t\n\t\t\t\t}\n\t\t\t\t// GTAO\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\n\t\t#elif AO_ALGORITHM == 3\n\t\t\t\t}\n\t\t\t\ttotalWeight += 1.;\n\t\t\t\tao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#else\n\n\t\t\t\tfloat fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n\t\t\t\tocclusion *= fallOff;\n\t\t\t\tvec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n\t\t\t\tocclusion *= step(1., dot(diff, diff));\n\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\tocclusion *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\tweight *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\ttotalWeight += weight;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#endif\t\n\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t#if AO_ALGORITHM != 1\n\t\t\tao = pow(ao, scale);\n\t\t#endif\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},Ou={resolutionScale:1,algorithm:0,samples:32,radius:.25,distanceExponent:2,thickness:.5,distanceFallOff:.5,scale:1,bias:.01,screenSpaceRadius:!1};class Uu{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n){this.needsUpdate=!0,this.parameters=Object.assign({},Ou),this._width=0,this._height=0,this._normalVectorSourceType=Mu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=Tu.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._renderPass=new sc,this._sceneClipBox=new et(new Je(-1,-1,-1),new Je(1,1,1)),this._sceneScale=1,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Mu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||Tu.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=(null==n?void 0:n.modulateRedChannel)||!1,(null==n?void 0:n.aoParameters)&&(this.parameters=n.aoParameters),n&&this.updateTextures(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new Ql,n=new Uint8Array(e*e*4);for(let i=0;i{const i=Bu(e,t,n);let r="vec3[SAMPLES](";for(let t=0;t{const i=[];for(let r=0;r\n#include \n\n#ifndef LUMINANCE_TYPE\n#define LUMINANCE_TYPE float\n#endif\n\n#ifndef SAMPLE_LUMINANCE\n#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n#endif\n\n#ifndef FRAGMENT_OUTPUT\n#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n#endif\n\nLUMINANCE_TYPE getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n}\n\nconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n}\n\nfloat getDepth(const vec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return textureLod(tDepth, uv.xy, 0.0).a;\n#else\n return textureLod(tDepth, uv.xy, 0.0).r;\n#endif\n}\n\nfloat fetchDepth(const ivec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return texelFetch(tDepth, uv.xy, 0).a;\n#else\n return texelFetch(tDepth, uv.xy, 0).r;\n#endif\n}\n\nvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nvec3 getViewNormal(const vec2 uv) {\n#if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n#elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n#else\n return computeNormalFromDepth(uv);\n#endif\n}\n\nvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout LUMINANCE_TYPE totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n \n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n LUMINANCE_TYPE lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n LUMINANCE_TYPE lumaSimilarity = max(1. - lumaDiff / lumaPhi, 0.);\n float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n LUMINANCE_TYPE w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\n denoised += w * neighborColor;\n totalWeight += w;\n}\n\nvoid main() {\n float depth = getDepth(vUv.xy);\t\n vec3 viewNormal = getViewNormal(vUv);\t\n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\n LUMINANCE_TYPE totalWeight = LUMINANCE_TYPE(1.);\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n #if SCREEN_SPACE_RADIUS == 1\n vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n vec2 sampleUv = vUv + offset;\n #else\n vec3 offsetViewPos = viewPos + vec3(sampleDir.xy, 0.) * sampleDir.z * radius;\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(offsetViewPos, 1.0); \n vec2 sampleUv = (samplePointNDC.xy / samplePointNDC.w * 0.5 + 0.5);\n #endif\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n denoised /= totalWeight + 1.0 - step(0.0, totalWeight);\n gl_FragColor = vec4(denoised, 1.);\n}"},ku={iterations:2,samples:16,rings:2,radiusExponent:1,radius:5,lumaPhi:10,depthPhi:2,normalPhi:4};class Hu{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._outputRenderTargetIndex].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n){this.needsUpdate=!0,this.parameters=Object.assign({},ku),this._width=0,this._height=0,this._normalVectorSourceType=Mu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=Tu.NORMAL_VECTOR_ALPHA,this._rgInputTexture=!0,this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._outputRenderTargetIndex=0,this._renderPass=new sc,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Mu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||Tu.NORMAL_VECTOR_ALPHA,this._rgInputTexture=(null==n?void 0:n.rgInputTexture)||!0,this._inputTexture=(null==n?void 0:n.inputTexture)||null,this.depthTexture=(null==n?void 0:n.depthTexture)||null,this.normalTexture=(null==n?void 0:n.normalTexture)||null,(null==n?void 0:n.poissonDenoisePassParameters)&&(this.parameters=n.poissonDenoisePassParameters),n&&this.updateTextures(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new Ql,n=new Uint8Array(e*e*4);for(let i=0;ie.dispose()))}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach((n=>n.setSize(e,t))),this.needsUpdate=!0}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const i=this._getRenderTargets();for(let t=0;t.001,r=e===Vu.HARD&&t>.001&&t<.999;return{fadeInPoissonShadow:i,fadeInHardShadow:r,onlyHardShadow:e===Vu.HARD&&!r,progressiveDenoise:!i&&!r&&n>1&&n<=this.parameters.progressiveDenoiseIterations+1}}render(e,t,n,i,r=Vu.FULL,a=Vu.FULL,s=0,o=0){if(!this._setRenderState())return;const l=this._getRenderConditions(a,s,o);let c=!1;!l.onlyHardShadow&&r===Vu.FULL&&this._evaluateIfUpdateIsNeeded(n)&&(this._renderShadowAndAo(e,t,n,i),c=!0);let h=l.onlyHardShadow?i:this.denoiseRenderTargetTexture;l.fadeInPoissonShadow&&(h=this._renderDynamicShadow(e,this.shadowAndAoRenderTargets.passRenderTarget.texture,i,s),c=!0),c?h=this._renderDenoise(e,n,l.fadeInPoissonShadow,!1):l.progressiveDenoise&&(h=this._renderDenoise(e,n,!1,!0)),l.fadeInHardShadow&&(h=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,i,s)),this._renderToTarget(e,h,l.onlyHardShadow)}_setRenderState(){return this.shadowAndAoRenderTargets.shadowEnabled=this.parameters.shadowIntensity>.01,!(!this.parameters.enabled||null===this.parameters.ao.algorithm&&!this.shadowAndAoRenderTargets.shadowEnabled||(this.needsUpdate&&(this._aoPass&&(this._aoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,i){var r;const a=null!==this.parameters.ao.algorithm&&this.parameters.aoIntensity>.01;this.gBufferRenderTarget.render(e,t,n),a||null===(r=this._aoPass)||void 0===r||r.clear(e,this.shadowAndAoRenderTargets.passRenderTarget),this.shadowAndAoRenderTargets.render(e,n,i),a&&this._renderAo(e,t,n)}_renderAo(e,t,n){const i=this.gBufferRenderTarget.depthBufferTexture,r=this.gBufferRenderTarget.gBufferTexture,a=this.shadowAndAoRenderTargets.passRenderTarget,s=e.autoClear;e.autoClear=!1;const o=this.aoRenderPass;o.depthTexture=i,o.normalTexture=r,o.render(e,n,t,a),e.autoClear=s}_renderDynamicShadow(e,t,n,i=1){const r=i<.999;return r&&(this._copyMaterial.update({texture:t,blending:0,colorTransform:Nl,multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),i>.001&&(this._blendMaterial.update({texture:n,blending:r?5:0,colorTransform:(new At).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,r?i:1),multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n,i){const r=this.denoisePass;return r.inputTexture=n?this.fadeRenderTarget.texture:i?r.texture:this.shadowAndAoRenderTargets.passRenderTarget.texture,r.render(e,t),r.texture}_renderToTarget(e,t,n){const i=n?this.parameters.shadowIntensity:this.parameters.aoIntensity,r=n?0:this.parameters.shadowIntensity;this._renderPass.renderScreenSpace(e,this._copyMaterial.update({texture:t,blending:5,colorTransform:Gl(i,r,0,1),multiplyChannels:1}),e.getRenderTarget())}}Wu.shadowTransform=(new At).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class ju{get passRenderTarget(){var e;return this._passRenderTarget=null!==(e=this._passRenderTarget)&&void 0!==e?e:new Ye(this._width,this._height,{samples:this._targetSamples,format:B,magFilter:E,minFilter:E}),this._passRenderTarget}get passRenderMaterial(){var e;return this._passRenderMaterial=null!==(e=this._passRenderMaterial)&&void 0!==e?e:new Xu({normalTexture:this._depthAndNormalTextures.gBufferTexture,depthTexture:this._depthAndNormalTextures.depthBufferTexture,noiseTexture:this.noiseTexture,sampleKernel:this.sampleKernel,floatGBufferRgbNormalAlphaDepth:this._depthAndNormalTextures.isFloatGBufferWithRgbNormalAlphaDepth}),this._passRenderMaterial}get noiseTexture(){var e;return this._noiseTexture=null!==(e=this._noiseTexture)&&void 0!==e?e:ac(5),this._noiseTexture}get sampleKernel(){return this._sampleKernel.length||(this._sampleKernel=(e=>{const t=[];for(let n=0;n\n \n float getDepth(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if DEPTH_BUFFER_ANTIALIAS == 1\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float d0 = texelFetch(tNormal, p, 0).w;\n vec2 depth = vec2(d0, 1.0);\n float d1 = texelFetch(tNormal, p + ivec2(1, 0), 0).w;\n depth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n float d2 = texelFetch(tNormal, p - ivec2(1, 0), 0).w;\n depth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n float d3 = texelFetch(tNormal, p + ivec2(0, 1), 0).w;\n depth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n float d4 = texelFetch(tNormal, p - ivec2(0, 1), 0).w;\n depth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n return depth.x / depth.y;\n #else\n return texture2D(tNormal, screenPosition).w;\n #endif\n #else \n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n \n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n \n vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraInverseProjectionMatrix * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n vec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if NORMAL_VECTOR_ANTIALIAS == 1\n vec2 uv = screenPosition;\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float c0 = texelFetch(tNormal, p, 0).a;\n float l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n float l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n float r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n float r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n float b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n float b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n float t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n float t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n #elif NORMAL_VECTOR_ANTIALIAS == 2\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n vec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n return normalize(normalVector);\n #else\n return texture2D(tNormal, screenPosition).xyz;\n #endif\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n\n vec3 getViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n return texture2D(tNormal, screenPosition).xyz;\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n \n void main() {\n \n float depth = getDepth(vUv);\n float viewZ = getViewZ(depth);\n \n vec3 viewPosition = getViewPosition(vUv, depth);\n vec3 viewNormal = getAntiAliasedViewNormal(vUv);\n vec3 worldPosition = (cameraWorldMatrix * vec4(viewPosition, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPosition, worldPosition - sceneBoxMax)));\n \n vec2 noiseScale = resolution.xy / vec2(textureSize(tNoise, 0));\n vec3 random = texture2D(tNoise, vUv * noiseScale).xyz * 2.0 - 1.0;\n \n // compute matrix used to reorient a kernel vector\n vec3 tangent = normalize(random - viewNormal * dot(random, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n \n float shOcclusion = texture2D(tShadow, vUv).r;\n float shSamples = 0.0;\n if (shIntensity >= 0.01 && length(viewNormal) > 0.01) {\n for (int i = 0; i < KERNEL_SIZE; i ++) {\n vec3 shSampleVector = kernelMatrix * sampleKernel[i]; // reorient sample vector in view space\n vec3 shSamplePoint = viewPosition + shSampleVector * shKernelRadius; // calculate sample point\n vec4 shSamplePointNDC = cameraProjectionMatrix * vec4(shSamplePoint, 1.0); // project point and calculate NDC\n shSamplePointNDC /= shSamplePointNDC.w;\n vec2 shSamplePointUv = shSamplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n vec3 shSampleNormal = getViewNormal(shSamplePointUv);\n float shDeltaZ = getViewZ(getDepth(shSamplePointUv)) - shSamplePoint.z;\n float w = step(abs(shDeltaZ), shKernelRadius) * max(0.0, dot(shSampleNormal, viewNormal));\n shSamples += w;\n shOcclusion += texture2D(tShadow, shSamplePointUv).r * w;\n }\n }\n \n shOcclusion = clamp(shOcclusion / (shSamples + 1.0), 0.0, 1.0);\n gl_FragColor = vec4(1., shOcclusion, 0.0, 1.0);\n }"};class Yu{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n){var i;this._width=e,this._height=t,this.parameters=Object.assign({enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4},n),this._copyMaterial=new jl({}),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new qu({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new oc(Xl,n),this._renderPass=null!==(i=null==n?void 0:n.renderPass)&&void 0!==i?i:new sc}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale;let i={};if(e){const e=new ar(t,n);e.format=U,e.type=I,i.minFilter=b,i.magFilter=b,i.depthTexture=e}else i.samples=1;return new Ye(t,n,Object.assign({format:N},i))}dispose(){var e,t,n;null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,i,r,a;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._intensityRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(r=this._blurRenderTarget)||void 0===r||r.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(a=this._reflectionIntensityMaterial)||void 0===a||a.update({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(let t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const i=this.parameters.intensity*t,r=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new At).set(r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,i),multiplyChannels:0,uvTransform:Vl}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}render(e,t,n,i=1){if(!(this.parameters.enabled&&n instanceof hi))return;const r=this._createGroundReflectionCamera(n);this._renderGroundReflection(e,t,r,this.reflectionRenderTarget),this._renderGroundReflectionIntensity(e,r,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,n,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,i),this._renderPass.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,i){const r=e.getRenderTarget();i&&e.setRenderTarget(i),e.render(t,n),i&&e.setRenderTarget(r)}_renderGroundReflectionIntensity(e,t,n){const i=e.getRenderTarget();e.setRenderTarget(n),this._renderPass.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(i)}blurReflection(e,t,n){const i=new Je(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),r=this.parameters.blurHorizontal/this._width,a=this.parameters.blurVertical/this._height*Math.abs(i.dot(new Je(0,0,1)));this._blurPass.render(e,n,[4*r,4*a],[4*r*(1+this.parameters.blurAscent),4*a*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class qu extends li{constructor(e){super({defines:Object.assign({},qu.shader.defines),uniforms:oi.clone(qu.shader.uniforms),vertexShader:qu.shader.vertexShader,fragmentShader:qu.shader.fragmentShader,blending:0}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}qu.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new be},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new At},cameraInverseProjectionMatrix:{value:new At},inverseViewMatrix:{value:new At},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include \n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec4 fragColor = texture2D(tDiffuse, uv).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha;\n gl_FragColor = fragColor * step(depth, 0.9999);\n }"};class Zu{constructor(e){this.grayMaterial=new yo({color:12632256,side:2,envMapIntensity:.4}),this._renderPass=new sc,this._sceneRenderer=e,this._environmentMapDecodeMaterial=new vc(!0,!1),this._environmentMapDecodeMaterial.blending=0,this._environmentMapDecodeMaterial.depthTest=!1}get _gBufferRenderTarget(){return this._sceneRenderer.gBufferRenderTarget}get _screenSpaceShadow(){return this._sceneRenderer.screenSpaceShadow}get _shadowAndAoPass(){return this._sceneRenderer.shadowAndAoPass}get _groundReflectionPass(){return this._sceneRenderer.groundReflectionPass}get _bakedGroundContactShadow(){return this._sceneRenderer.bakedGroundContactShadow}dispose(){var e,t;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.grayMaterial.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new jl,this._copyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new Yl({depthTexture:this._gBufferRenderTarget.textureWithDepthValue,depthFilter:this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?new je(0,0,0,1):new je(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}render(e,t,n,i,r,a,s){e(i,r,a),"color"!==s?("grayscale"===s?this._sceneRenderer.renderCacheManager.render("debug",r,(()=>{this._renderPass.renderWithOverrideMaterial(i,r,a,this.grayMaterial,null,0,1)})):t(i,r,a),n(i,r,a),this._renderDebugPass(i,r,a,s)):i.render(r,a)}_renderDebugPass(e,t,n,i){var r,a,s,o,l,c;switch(i){default:break;case"lineardepth":this._renderPass.renderScreenSpace(e,this._getDepthRenderMaterial(n),null);break;case"g-normal":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(r=this._gBufferRenderTarget)||void 0===r?void 0:r.gBufferTexture,blending:0,colorTransform:(new At).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new je(.5,.5,.5,1),multiplyChannels:0,uvTransform:Hl}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.gBufferTexture,blending:0,colorTransform:Ol,colorBase:kl,multiplyChannels:0,uvTransform:Hl}),null);break;case"g-depth":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(s=this._gBufferRenderTarget)||void 0===s?void 0:s.gBufferTexture,blending:0,colorTransform:Ul,colorBase:kl,multiplyChannels:0,uvTransform:Hl}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(o=this._gBufferRenderTarget)||void 0===o?void 0:o.depthBufferTexture,blending:0,colorTransform:Fl,colorBase:kl,multiplyChannels:0,uvTransform:Hl}),null);break;case"ssao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:0,colorTransform:Bl,colorBase:zl,multiplyChannels:0,uvTransform:Hl}),null);break;case"ssaodenoise":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:Bl,colorBase:zl,multiplyChannels:0,uvTransform:Hl}),null);break;case"shadowmap":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._screenSpaceShadow.shadowTexture,blending:0,colorTransform:Bl,colorBase:zl,multiplyChannels:0,uvTransform:Hl}),null);break;case"shadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:0,colorTransform:Wu.shadowTransform,colorBase:zl,multiplyChannels:0,uvTransform:Hl}),null);break;case"shadowblur":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:Wu.shadowTransform,colorBase:zl,multiplyChannels:0,uvTransform:Hl}),null);break;case"shadowfadein":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.fadeRenderTarget.texture,blending:0,colorTransform:Wu.shadowTransform,colorBase:zl,multiplyChannels:0,uvTransform:Hl}),null);break;case"shadowandao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:Gl(this._shadowAndAoPass.parameters.aoIntensity,this._shadowAndAoPass.parameters.shadowIntensity,0,1),colorBase:zl,multiplyChannels:1,uvTransform:Hl}),null);break;case"groundreflection":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._groundReflectionPass.reflectionRenderTarget.texture,blending:0,colorTransform:Nl,colorBase:zl,multiplyChannels:0,uvTransform:Vl}),null);break;case"bakedgroundshadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._bakedGroundContactShadow.renderTarget.texture,blending:0,colorTransform:Nl,colorBase:zl,multiplyChannels:0,uvTransform:Hl}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(t.environment),this._renderPass.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(l=t.userData)||void 0===l?void 0:l.environmentDefinition){const n=this._sceneRenderer.width/this._sceneRenderer.height,i=new Oi(-1,1,1/n,-1/n,-1,1),r=null===(c=t.userData)||void 0===c?void 0:c.environmentDefinition.createDebugScene(e,t,this._sceneRenderer.screenSpaceShadow.parameters.maximumNumberOfLightSources);r.background=new gn(16777215),e.render(r,i)}}}}var Ku;!function(e){e[e.HIGHEST=0]="HIGHEST",e[e.HIGH=1]="HIGH",e[e.MEDIUM=2]="MEDIUM",e[e.LOW=3]="LOW"}(Ku||(Ku={}));class Ju{constructor(e,t,n){this.debugOutput="off",this._prevDebugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.movingCamera=!1,this.groundLevel=0,this.uiInteractionMode=!1,this._noUpdateNeededCount=0,this._noOStaticFrames=0,this._cameraUpdate=new rc,this.width=0,this.height=0,this._maxSamples=1,this._cameraChanged=!0,this.boundingVolume=new nc,this._boundingVolumeSet=!1,this.renderCacheManager=new nu,this._renderPass=new sc,this.selectedObjects=[],this.groundGroup=new Ja,this._qualityLevel=Ku.HIGHEST,this._qualityMap=new Map,this.width=t,this.height=n,this._maxSamples=ic(e),this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new iu((e=>e===this.groundGroup))),this.renderCacheManager.registerCache("debug",new iu),this.renderCacheManager.registerCache("floorDepthWrite",new ru((e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor}))),this.gBufferRenderTarget=new ou(this.renderCacheManager,{shared:!0,capabilities:e.capabilities,width:this.width,height:this.height,samples:1,renderPass:this._renderPass}),this.shadowAndAoPass=new Wu(this.width,this.height,1,{gBufferRenderTarget:this.gBufferRenderTarget}),this.screenSpaceShadow=new wu(this.renderCacheManager,new be(this.width,this.height),{samples:this._maxSamples,alwaysUpdate:!1}),this.groundReflectionPass=new Yu(this.width,this.height,{renderPass:this._renderPass}),this._shadowAndAoGroundPlane=new cu(null),this.bakedGroundContactShadow=new hu(this.renderer,this.groundGroup,{renderPass:this._renderPass,renderCacheManager:this.renderCacheManager,sharedShadowGroundPlane:this._shadowAndAoGroundPlane}),this.groundGroup.rotateX(-Math.PI/2),this.outlineRenderer=new mu(null,this.width,this.height,{gBufferRenderTarget:this.gBufferRenderTarget}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderTarget.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadow.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadow.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:Vu.OFF},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",(()=>{console.log("webglcontextlost")})),e.domElement.addEventListener("webglcontextrestored",(()=>{console.log("webglcontextrestored"),this._forceEnvironmentMapUpdate(this.renderer)}))}dispose(){var e,t;null===(e=this._debugPass)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.gBufferRenderTarget.dispose(),this.screenSpaceShadow.dispose(),this.shadowAndAoPass.dispose(),this.outlineRenderer.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this.gBufferRenderTarget.setSize(e,t),this.screenSpaceShadow.setSize(e,t),this.shadowAndAoPass.setSize(e,t),this.outlineRenderer.setSize(e,t),this.groundReflectionPass.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}applyCurrentParameters(){this._qualityMap.has(this._qualityLevel)&&(this.updateParameters(this._qualityMap.get(this._qualityLevel)),this.bakedGroundContactShadow.applyParameters()),this.uiInteractionMode&&this.updateParameters({groundReflectionParameters:{enabled:!1}})}clearCache(){this.renderCacheManager.clearCache()}forceShadowUpdates(e){this.clearCache(),this.gBufferRenderTarget.needsUpdate=!0,this.screenSpaceShadow.forceShadowUpdate(),this.shadowAndAoPass.needsUpdate=!0,e&&(this.bakedGroundContactShadow.needsUpdate=!0)}updateParameters(e){void 0!==e.shAndAoPassParameters&&this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters),void 0!==e.bakedGroundContactShadowParameters&&this.bakedGroundContactShadow.updateParameters(e.bakedGroundContactShadowParameters),void 0!==e.screenSpaceShadowMapParameters&&this.screenSpaceShadow.updateParameters(e.screenSpaceShadowMapParameters),void 0!==e.groundReflectionParameters&&this.groundReflectionPass.updateParameters(e.groundReflectionParameters),void 0!==e.outlineParameters&&this.outlineRenderer.updateParameters(e.outlineParameters),void 0!==e.effectSuspendFrames&&(this.parameters.effectSuspendFrames=e.effectSuspendFrames),void 0!==e.effectFadeInFrames&&(this.parameters.effectFadeInFrames=e.effectFadeInFrames),void 0!==e.suspendGroundReflection&&(this.parameters.suspendGroundReflection=e.suspendGroundReflection),void 0!==e.shadowOnCameraChange&&(this.parameters.shadowOnCameraChange=e.shadowOnCameraChange)}addRectAreaLight(e,t){this.environmentLights=!1,this.screenSpaceShadow.addRectAreaLight(e,t),this.shadowAndAoPass.needsUpdate=!0}updateRectAreaLights(e,t){e.length>0&&(this.environmentLights=!1),this.screenSpaceShadow.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadow.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache(),this._boundingVolumeSet=!0,this.gBufferRenderTarget.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(e);const n=this.boundingVolume.size,i=(n.x+n.y+n.z)/3,r=Math.min(n.x,n.y,n.z),a=Math.max(n.x,n.y,n.z),s=r<.5?r/.5:n.z>5?n.z/5:1;this.bakedGroundContactShadow.setScale(t?i:s,i),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,a)),this.screenSpaceShadow.updateBounds(this.boundingVolume,i),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?i:Math.min(1,2*a))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_setRenderState(e,t){var n;const i=this.debugOutput!==this._prevDebugOutput;this._prevDebugOutput=this.debugOutput,this.screenSpaceShadow.parameters.alwaysUpdate=this.shadowAndAoPass.parameters.alwaysUpdate,this._cameraChanged=this._cameraUpdate.changed(t),(n=this.gBufferRenderTarget).needsUpdate||(n.needsUpdate=this._cameraChanged||i)}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,i;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const r=e.userData;if(r&&((null===(i=t.userData)||void 0===i?void 0:i.environmentDefinition.needsUpdate)||!r.environmentTexture||r.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(r.environmentDefinition=n,r.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadow.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==r?void 0:r.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}_setGroundVisibility(e){this._shadowAndAoGroundPlane.setVisibility(e)}render(e,t){e.add(this.groundGroup),this._setRenderState(e,t),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.movingCamera?[]:this.selectedObjects),this.renderer.setRenderTarget(null),this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput?this._renderDebug(this.renderer,e,t):(this.renderPreRenderPasses(this.renderer,e,t),this._renderScene(this.renderer,e,t),this.renderPostProcessingEffects(this.renderer,e,t)),e.remove(this.groundGroup)}_renderDebug(e,t,n){var i;this._debugPass=null!==(i=this._debugPass)&&void 0!==i?i:new Zu(this),this._debugPass.render(((e,t,n)=>this.renderPreRenderPasses(e,t,n)),((e,t,n)=>this._renderScene(e,t,n)),((e,t,n)=>this.renderPostProcessingEffects(e,t,n)),e,t,n,this.debugOutput)}renderPreRenderPasses(e,t,n){this._renderGroundContactShadow(t)}_renderScene(e,t,n){this.renderCacheManager.onBeforeRender("floorDepthWrite",t),this._setGroundVisibility(this.bakedGroundContactShadow.parameters.enabled),e.render(t,n),this._setGroundVisibility(!1),this.renderCacheManager.onAfterRender("floorDepthWrite")}renderPostProcessingEffects(e,t,n){this.renderShadowAndAo(e,t,n),this._renderOutline()}_renderGroundContactShadow(e){this.bakedGroundContactShadow.needsUpdate&&this.bakedGroundContactShadow.updateBounds(this.boundingVolume,this.groundLevel),this.bakedGroundContactShadow.render(e)}renderShadowAndAo(e,t,n){const i=this._evaluateIfShadowAndAoUpdateIsNeeded(n);if(i.needsUpdate||i.shadowOnCameraChange!==Vu.OFF){if(!this.parameters.suspendGroundReflection||i.needsUpdate){const r=this.parameters.suspendGroundReflection?i.intensityScale:1;this._renderGroundReflection(e,t,n,r)}this.gBufferRenderTarget.needsUpdate=i.needsUpdate||i.shadowOnCameraChange===Vu.POISSON,this._setGroundVisibility(this._boundingVolumeSet&&this.shadowAndAoPass.parameters.aoOnGround),this.gBufferRenderTarget.render(e,t,n),this._setGroundVisibility(!1),this.shadowAndAoPass.parameters.shadowIntensity>0&&(this._setGroundVisibility(this.shadowAndAoPass.parameters.shadowOnGround),this.screenSpaceShadow.renderShadowMap(e,t,n),this._setGroundVisibility(!1)),this.shadowAndAoPass.render(e,t,n,this.screenSpaceShadow.shadowTexture,i.needsUpdate?Vu.FULL:i.shadowOnCameraChange,i.shadowOnCameraChange,1-i.intensityScale,this._noOStaticFrames)}}_evaluateIfShadowAndAoUpdateIsNeeded(e){const t=this.shadowAndAoPass.parameters.alwaysUpdate||this.screenSpaceShadow.needsUpdate||this.screenSpaceShadow.shadowTypeNeedsUpdate;let n=(this.shadowAndAoPass.parameters.enabled||this.groundReflectionPass.parameters.enabled)&&this._cameraChanged,i=1;return n&&(this._noUpdateNeededCount=0,this._noOStaticFrames=0),t||(this._noUpdateNeededCount++,n=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,i=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),t||1!==i||this._noOStaticFrames++,n=t||n,{needsUpdate:n,shadowOnCameraChange:!n||i<.99?this.parameters.shadowOnCameraChange:Vu.OFF,intensityScale:i}}_renderGroundReflection(e,t,n,i=1){this.groundReflectionPass.parameters.enabled&&this.renderCacheManager.render("inivisibleGround",t,(()=>{this.groundReflectionPass.render(e,t,n,i)}))}_renderOutline(){if(this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass){const e=this.renderer.getClearColor(new gn),t=this.renderer.getClearAlpha();"outline"===this.debugOutput&&(this.renderer.setClearColor(0,255),this.renderer.clear(!0,!1,!1)),this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.render(this.renderer,null,null,0,!1),"outline"===this.debugOutput&&this.renderer.setClearColor(e,t)}}}class Qu extends Qt{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 be(.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 $u=new Je,ep=new At,tp=new At,np=new Je,ip=new Je;class rp extends Ja{constructor(e,t,n){super(),this.arrowNeedsUpdate=!0,this.labelTextClientWidth=0,this.startPosition=e.clone(),this.endPosition=t.clone(),this.parameters=Object.assign({shaftPixelWidth:10,shaftPixelOffset:3,arrowPixelWidth:30,arrowPixelHeight:50,color:0,labelClass:"label",deviceRatio:1,autoLabelTextUpdate:!0,autoLabelRotationUpdate:!0},n),this.startShaftMaterial=new ap,this.startShaft=new ti(new Mi(2,1).translate(0,.5,0),this.startShaftMaterial),this.startShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!0,e,n,r)},this.add(this.startShaft),this.endShaftMaterial=new ap,this.endShaft=new ti(new Mi(2,1).translate(0,.5,0),this.endShaftMaterial),this.endShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!1,e,n,r)},this.add(this.endShaft),this.startArrowMaterial=new sp,this.startArrow=new ti(new Mi(2,1).translate(0,.5,0),this.startArrowMaterial),this.startArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!0,e,n,r)},this.add(this.startArrow),this.endArrowMaterial=new sp,this.endArrow=new ti(new Mi(2,1).translate(0,.5,0),this.endArrowMaterial),this.endArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!1,e,n,r)},this.add(this.endArrow),this.arrowLabel=this.createArrowLabel("0.000",this.parameters),this.add(this.arrowLabel),this.updateArrow()}createArrowLabel(e,t){var n,i,r,a,s,o;const l=document.createElement("div"),c=document.createElement("div");l.appendChild(c),c.className=null!==(n=t.labelClass)&&void 0!==n?n:"",c.textContent=e,c.style.backgroundColor="transparent",c.style.color=new gn(null!==(i=t.color)&&void 0!==i?i:0).getStyle();const h=new Qu(l);return h.position.set(0,0,0),h.center.set(null!==(a=null===(r=t.origin)||void 0===r?void 0:r.x)&&void 0!==a?a:.5,null!==(o=null===(s=t.origin)||void 0===s?void 0:s.y)&&void 0!==o?o:.5),h.layers.set(0),h}setPosition(e,t,n=0,i=0){const r=t.clone().sub(e).normalize();this.startPosition.copy(e.clone().add(r.clone().multiplyScalar(n))),this.endPosition.copy(t.clone().add(r.clone().multiplyScalar(-i))),this.arrowNeedsUpdate=!0}setAngle(e){const t=`${e.toFixed(0)}deg`;this.arrowLabel.element.children[0].style.rotate=t}setLabel(e){const t=this.arrowLabel.element.children[0];t.textContent=e,this.labelTextClientWidth=t.clientWidth*this.parameters.deviceRatio}updateArrow(){const e=this.startPosition.clone().applyMatrix4(this.matrixWorld),t=this.endPosition.clone().applyMatrix4(this.matrixWorld),n=t.clone().sub(e),i=n.length();n.multiplyScalar(1/i);const r=new Je(0,1,0).cross(n),a=Math.acos(new Je(0,1,0).dot(n));this.setModelMatrix(this.startShaft,e,i,r,a),this.setModelMatrix(this.endShaft,t,i,r,a),this.setModelMatrix(this.startArrow,e,1,r,a),this.setModelMatrix(this.endArrow,t,1,r,a+Math.PI)}updateArrowLabel(e,t){var n,i;const r=this.startPosition.distanceTo(this.endPosition).toFixed(3),a=this.startPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),s=this.endPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),o=s.clone().add(a).multiplyScalar(.5).applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);this.arrowLabel.position.copy(o);const l=e.getRenderTarget(),c=null!==(n=null==l?void 0:l.width)&&void 0!==n?n:e.domElement.clientWidth,h=null!==(i=null==l?void 0:l.height)&&void 0!==i?i:e.domElement.clientHeight,d=s.clone().sub(a),u=180*Math.atan2(-d.y,d.x*c/h)/Math.PI;this.parameters.autoLabelRotationUpdate&&this.setAngle(u),this.parameters.autoLabelTextUpdate&&this.setLabel(r)}setModelMatrix(e,t,n,i,r){e.scale.set(1,1,1),e.rotation.set(0,0,0),e.position.set(0,0,0),e.applyMatrix4((new At).makeScale(1,.5*n,1)),e.applyMatrix4((new At).makeRotationAxis(i,r)),e.applyMatrix4((new At).makeTranslation(t.x,t.y,t.z))}updateShaftMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof ap){const s=t.getRenderTarget(),o=new be;t.getSize(o);const l=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:o.x,c=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:o.y,h=this.startPosition.clone().applyMatrix4(this.matrixWorld),d=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:l,height:c,camera:n,start:e?h:d,end:e?d:h,shaftPixelWidth:this.parameters.shaftPixelWidth,shaftPixelOffset:this.parameters.shaftPixelOffset,arrowPixelSize:new be(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),labelPixelWidth:this.labelTextClientWidth,color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}updateArrowMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof sp){const s=t.getRenderTarget(),o=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:t.domElement.clientWidth,l=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:t.domElement.clientHeight,c=this.startPosition.clone().applyMatrix4(this.matrixWorld),h=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:o,height:l,camera:n,start:e?c:h,end:e?h:c,arrowPixelSize:new be(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}}class ap extends li{constructor(e){super({defines:Object.assign({},ap.shader.defines),uniforms:oi.clone(ap.shader.uniforms),vertexShader:ap.shader.vertexShader,fragmentShader:ap.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.shaftPixelWidth)&&(this.uniforms.shaftPixelWidth.value=e.shaftPixelWidth),void 0!==(null==e?void 0:e.shaftPixelOffset)&&(this.uniforms.shaftPixelOffset.value=e.shaftPixelOffset),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.labelPixelWidth)&&(this.uniforms.labelPixelWidth.value=e.labelPixelWidth),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new gn(e.color)),this}}ap.shader={uniforms:{resolution:{value:new be},start:{value:new Je},end:{value:new Je},shaftPixelWidth:{value:10},shaftPixelOffset:{value:10},arrowPixelSize:{value:new be},labelPixelWidth:{value:0},color:{value:new gn}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform float shaftPixelWidth;\nuniform float shaftPixelOffset;\nuniform vec2 arrowPixelSize;\nuniform float labelPixelWidth;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n vec4 shaftEnd = vec4(clipEnd.xy / clipEnd.w * clipStart.w, clipStart.zw);\n shaftEnd.xy -= clipDir * (labelPixelWidth * 0.5 + shaftPixelOffset) * pixelToNdcScale(gl_Position);\n gl_Position.xy = mix(clipStart.xy / clipStart.w, shaftEnd.xy / shaftEnd.w, position.y * 0.5) * gl_Position.w;\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * shaftPixelWidth * 0.5 * pixelToNdcScale(gl_Position);\n\n vec4 clipCenter = clipStart;\n float d = arrowPixelSize.y * (1.0 + RADIUS_RATIO) - length(arrowPixelSize * vec2(0.5, RADIUS_RATIO));\n clipCenter.xy += clipDir * (d + shaftPixelOffset + shaftPixelWidth * 0.5) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n arrowDir = clipDir;\n}",fragmentShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform float shaftPixelWidth;\nuniform vec3 color;\n\nvoid main() {\n if (dot(arrowDir, posPixel - centerPixel) < 0.0 && length(posPixel - centerPixel) > shaftPixelWidth * 0.5)\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};class sp extends li{constructor(e){super({defines:Object.assign({},sp.shader.defines),uniforms:oi.clone(sp.shader.uniforms),vertexShader:sp.shader.vertexShader,fragmentShader:sp.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new gn(e.color)),this}}sp.shader={uniforms:{resolution:{value:new be},start:{value:new Je},end:{value:new Je},arrowPixelSize:{value:new be},color:{value:new gn}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform vec2 arrowPixelSize;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n gl_Position.xy += clipDir * position.y * arrowPixelSize.y * pixelToNdcScale(gl_Position);\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * arrowPixelSize.x * 0.5 * pixelToNdcScale(gl_Position);\n\n arrowUv = position.xy;\n\n vec4 clipCenter = clipStart;\n clipCenter.xy += clipDir * arrowPixelSize.y * (1.0 + RADIUS_RATIO) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n}",fragmentShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec2 arrowPixelSize;\nuniform vec3 color;\n\nvoid main() {\n if (abs(arrowUv.x) > abs(arrowUv.y))\n discard;\n if (length(posPixel - centerPixel) < length(arrowPixelSize * vec2(0.5, RADIUS_RATIO)))\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};const op="front",lp="all_around";class cp extends Ec{constructor(e={}){super(),this._parameters={},this._parameters=e}generateScene(e,t){const n=new hp(Object.assign(Object.assign({},this._parameters),{lightIntensity:e*(this._parameters.lightIntensity||1),topLightIntensity:e*(this._parameters.topLightIntensity||1),sidLightIntensity:e*(this._parameters.sidLightIntensity||1)}));return n.rotation.y=t,n}}class hp extends rs{constructor(e={}){var t;super(),this._type=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:lp,this._topLightIntensity=(null==e?void 0:e.topLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideLightIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideReflectorIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._ambientLightIntensity=(null==e?void 0:e.ambientLightIntensity)||.25,this._colorVariation=(null==e?void 0:e.colorVariation)||.5,this._lightGeometry=new ii,this._lightGeometry.deleteAttribute("uv"),this.generateScene(this)}generateScene(e){switch(this._type){default:case lp:this._createAllAroundSceneLight(e);break;case op:this._createFrontSceneLight(e)}}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}_createAllAroundSceneLight(e){const t=new pl(16777215);t.intensity=this._ambientLightIntensity,this.add(t),this._createTopLight(e,6,1);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);t%2==0?this._createReflector(e,new be(i,r),3,1,1):this._createSideLight(e,new be(i,r),(t-1)/2,15,1.1,.33)}}_createFrontSceneLight(e){const t=new pl(16777215);t.intensity=this._ambientLightIntensity,this.add(t),this._createTopLight(e,5,.9);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);if(0===t){this._createReflector(e,new be(i,r),3,.8,.4);for(let n=0;n<2;n++){const i=(t-.2+.4*n)*Math.PI*2/6,r=Math.sin(i),a=Math.cos(i);this._createSideLight(e,new be(r,a),(t-1)/2,20,1.1,.75)}}else this._createReflector(e,new be(i,r),3,.8,1)}}_createAreaLightMaterial(e,t,n){const i=new yn;return i.color.set(e,null!=t?t:e,null!=n?n:e),i}_createTopLight(e,t,n){const i=new ti(this._lightGeometry,this._createAreaLightMaterial(t*this._topLightIntensity));i.position.set(0,20,0),i.scale.set(5*n,.1,5*n),e.add(i)}_createSideLight(e,t,n,i,r,a){for(let s=0;s<3;s++){const o=i*this._sideLightIntensity,l=new ti(this._lightGeometry,this._createAreaLightMaterial((s+n)%3==0?o:o*(1-this._colorVariation),(s+n)%3==1?o:o*(1-this._colorVariation),(s+n)%3==2?o:o*(1-this._colorVariation))),c=(1===s?-t.y:2===s?t.y:0)/Math.sqrt(2),h=0===s?0:1,d=(1===s?t.x:2===s?-t.x:0)/Math.sqrt(2);l.position.set(15*t.x+1.1*c*r,15*a+1.1*h*r,15*t.y+1.1*d*r),l.rotation.set(0,Math.atan2(t.x,t.y),0),l.scale.setScalar(r),e.add(l)}}_createReflector(e,t,n,i,r){const a=new ti(this._lightGeometry,this._createAreaLightMaterial(n*this._sideReflectorIntensity));a.position.set(15*t.x,5*r,15*t.y),a.rotation.set(0,Math.atan2(t.x,t.y),0),a.scale.set(10*i,12*i*r,10*i),e.add(a)}}const dp={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:Vu.FULL},up={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:Vu.POISSON},pp={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:Vu.HARD},fp={enabled:!0,aoOnGround:!0,shadowOnGround:!0,aoIntensity:1,shadowIntensity:1,ao:{algorithm:4,samples:16,radius:.5,distanceExponent:2,thickness:1,distanceFallOff:1,scale:1,bias:.01,screenSpaceRadius:!1}},mp={enableGroundBoundary:!1,directionalDependency:1,directionalExponent:1,groundBoundary:0,fadeOutDistance:.2,fadeOutBlur:5},gp=new Map([[Ku.HIGHEST,Object.assign(Object.assign({},dp),{shAndAoPassParameters:fp,screenSpaceShadowMapParameters:mp,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[Ku.HIGH,Object.assign(Object.assign({},up),{shAndAoPassParameters:fp,screenSpaceShadowMapParameters:mp,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[Ku.MEDIUM,Object.assign(Object.assign({},pp),{shAndAoPassParameters:fp,screenSpaceShadowMapParameters:mp,groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}})],[Ku.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]]);class vp extends ti{constructor(e,t={}){const n=[e.isCubeTexture?"#define ENVMAP_TYPE_CUBE":""].join("\n")+"\n\n\t\t\t\tvarying vec3 vWorldPosition;\n\n\t\t\t\tuniform float radius;\n\t\t\t\tuniform float height;\n\t\t\t\tuniform float angle;\n\n\t\t\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\t\t\tuniform samplerCube map;\n\n\t\t\t\t#else\n\n\t\t\t\t\tuniform sampler2D map;\n\n\t\t\t\t#endif\n\n\t\t\t\t// From: https://www.shadertoy.com/view/4tsBD7\n\t\t\t\tfloat diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r ) \n\t\t\t\t{\n\n\t\t\t\t\tfloat d = dot ( rd, n );\n\n\t\t\t\t\tif( d > 0.0 ) { return 1e6; }\n\n\t\t\t\t\tvec3 o = ro - c;\n\t\t\t\t\tfloat t = - dot( n, o ) / d;\n\t\t\t\t\tvec3 q = o + rd * t;\n\n\t\t\t\t\treturn ( dot( q, q ) < r * r ) ? t : 1e6;\n\n\t\t\t\t}\n\n\t\t\t\t// From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm\n\t\t\t\tfloat sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra ) {\n\n\t\t\t\t\tvec3 oc = ro - ce;\n\t\t\t\t\tfloat b = dot( oc, rd );\n\t\t\t\t\tfloat c = dot( oc, oc ) - ra * ra;\n\t\t\t\t\tfloat h = b * b - c;\n\n\t\t\t\t\tif( h < 0.0 ) { return -1.0; }\n\n\t\t\t\t\th = sqrt( h );\n\n\t\t\t\t\treturn - b + h;\n\n\t\t\t\t}\n\n\t\t\t\tvec3 project() {\n\n\t\t\t\t\tvec3 p = normalize( vWorldPosition );\n\t\t\t\t\tvec3 camPos = cameraPosition;\n\t\t\t\t\tcamPos.y -= height;\n\n\t\t\t\t\tfloat intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius );\n\t\t\t\t\tif( intersection > 0.0 ) {\n\n\t\t\t\t\t\tvec3 h = vec3( 0.0, - height, 0.0 );\n\t\t\t\t\t\tfloat intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius );\n\t\t\t\t\t\tp = ( camPos + min( intersection, intersection2 ) * p ) / radius;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tp = vec3( 0.0, 1.0, 0.0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\treturn p;\n\n\t\t\t\t}\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 projectedWorldPosition = project();\n\n\t\t\t\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\t\t\t\tvec3 outcolor = textureCube( map, projectedWorldPosition ).rgb;\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tvec3 direction = normalize( projectedWorldPosition );\n\t\t\t\t\t\tvec2 uv = equirectUv( direction );\n\t\t\t\t\t\tvec3 outcolor = texture2D( map, uv ).rgb;\n\n\t\t\t\t\t#endif\n\n\t\t\t\t\tgl_FragColor = vec4( outcolor, 1.0 );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t\t",i={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}};super(new po(1,16),new li({uniforms:i,fragmentShader:n,vertexShader:"\n\t\t\tvarying vec3 vWorldPosition;\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) );\n\t\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t}\n\t\t\t",side:2}))}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}const _p=e.p+"916b55ac1b4c4c11f375.envmap";var xp=function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))};class yp{constructor(){this.materials=[],this.materialId=""}updateMaterialUI(e,t){var n,i;this.materialFolder&&(e.removeFolder(this.materialFolder),this.materialProperties=void 0),this.materialFolder=e.addFolder("Materials"),this.materials=t,this.materialId=null!==(i=null===(n=t[0])||void 0===n?void 0:n.materialId)&&void 0!==i?i:"";const r=t.map((e=>{let t=e.materialId;return{materialId:e.materialId,name:t}}));let a=Object.assign({},...r.map((e=>({[e.name]:e.materialId}))));this.materialFolder.add(this,"materialId",a).onChange((e=>this.updateMaterialPropertiesUI(e))),this.updateMaterialPropertiesUI(this.materialId)}updateMaterialPropertiesUI(e){var t,n,i,r,a,s,o,l,c,h;if(this.materialId=e,!this.materialFolder)return;this.materialProperties&&(this.materialFolder.removeFolder(this.materialProperties),this.materialProperties=void 0);const d=this.materials.find((t=>t.materialId===e));if(!d)return;const u=d.material;if(!u)return;const p={color:null!==(n=null===(t=u.color)||void 0===t?void 0:t.getHex())&&void 0!==n?n:16777215,specularColor:null!==(r=null===(i=u.color)||void 0===i?void 0:i.getHex())&&void 0!==r?r:16777215,emissive:null!==(s=null===(a=u.emissive)||void 0===a?void 0:a.getHex())&&void 0!==s?s:16777215,sheenColor:null!==(l=null===(o=u.emissive)||void 0===o?void 0:o.getHex())&&void 0!==l?l:16777215,attenuationColor:null!==(h=null===(c=u.emissive)||void 0===c?void 0:c.getHex())&&void 0!==h?h:16777215};let f="properties";d.material.userData&&(d.material.userData.diffuseMap&&(f+=d.material.userData.diffuseMapHasAlpha?" RGBA":" RGB"),d.material.userData.normalMap&&(f+=" XYZ"),d.material.userData.ormMap&&(f+=" ORM")),this.materialProperties=this.materialFolder.addFolder(f),this.materialProperties.addColor(p,"color").onChange(yp.handleColorChange(u.color,!0)),this.materialProperties.add(u,"opacity",0,1).onChange((e=>{const t=e<1;t!==u.transparent&&(u.transparent=t,u.needsUpdate=!0)}));try{this.materialProperties.add(u,"metalness",0,1),this.materialProperties.add(u,"roughness",0,1),this.materialProperties.add(u,"transmission",0,1),this.materialProperties.add(u,"ior",1,2.333),this.materialProperties.add(u,"specularIntensity",0,1),this.materialProperties.addColor(p,"specularColor").onChange(yp.handleColorChange(u.specularColor,!0)),this.materialProperties.add(u,"reflectivity",0,1),this.materialProperties.add(u,"clearcoat",0,1),this.materialProperties.add(u,"clearcoatRoughness",0,1),this.materialProperties.add(u,"sheen",0,1),this.materialProperties.add(u,"sheenRoughness",0,1),this.materialProperties.addColor(p,"sheenColor").onChange(yp.handleColorChange(u.sheenColor,!0)),this.materialProperties.add(u,"emissiveIntensity",0,1),this.materialProperties.addColor(p,"emissive").onChange(yp.handleColorChange(u.emissive,!0)),this.materialProperties.add(u,"attenuationDistance",0,50),this.materialProperties.addColor(p,"attenuationColor").onChange(yp.handleColorChange(u.attenuationColor,!0)),this.materialProperties.add(u,"thickness",0,50)}catch(e){console.log(e)}}static handleColorChange(e,t=!1){return n=>{"string"==typeof n&&(n=n.replace("#","0x")),e.setHex(n),!0===t&&e.convertSRGBToLinear()}}}var Sp=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i=a+1e3&&(o.update(1e3*s/(e-a),100),a=e,s=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};Sp.Panel=function(e,t,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,c=3*s,h=2*s,d=3*s,u=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,c,h),g.fillRect(d,u,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,u,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,o,u),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(i)+"-"+a(r)+")",c,h),g.drawImage(m,d+s,u,p-s,f,d,u,p-s,f),g.fillRect(d+p-s,u,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-s,u,s,a((1-l/v)*f))}}};const wp=Sp;function bp(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),a=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),c=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var h=e.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}return"CSS_RGB"===n?"rgb("+i+","+r+","+a+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+a+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+a+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+a+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+",a:"+s+"}":"unknown format"}var Mp=Array.prototype.forEach,Tp=Array.prototype.slice,Ep={BREAK:{},extend:function(e){return this.each(Tp.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(Tp.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=Tp.call(arguments);return function(){for(var t=Tp.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(Mp&&e.forEach&&e.forEach===Mp)e.forEach(t,n);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r1?Ep.toArray(arguments):arguments[0];return Ep.each(Ap,(function(t){if(t.litmus(e))return Ep.each(t.conversions,(function(t,n){if(Rp=t.read(e),!1===Cp&&!1!==Rp)return Cp=Rp,Rp.conversionName=n,Rp.conversion=t,Ep.BREAK})),Ep.BREAK})),Cp},Lp=void 0,Dp={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,a],[s,n,a],[a,n,o],[a,s,n],[o,a,n],[n,a,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),a=r-i,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(s/=6)<0&&(s+=1),{h:360*s,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Lp=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var Jp=function(e){function t(e,n,i){Np(this,t);var r=Bp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,Ep.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=Kp(r.__impliedStep),r}return Fp(t,e),Op(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Up(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=Kp(e),this}}]),t}(Vp),Qp=function(e){function t(e,n,i){Np(this,t);var r=Bp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var a=r,s=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=s-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),s=e.clientY}function c(){Xp.unbind(window,"mousemove",l),Xp.unbind(window,"mouseup",c),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),Xp.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Ep.isNaN(e)||a.setValue(e)})),Xp.bind(r.__input,"blur",(function(){o()})),Xp.bind(r.__input,"mousedown",(function(e){Xp.bind(window,"mousemove",l),Xp.bind(window,"mouseup",c),s=e.clientY})),Xp.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Fp(t,e),Op(t,[{key:"updateDisplay",value:function(){var e,n,i;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,i=Math.pow(10,n),Math.round(e*i)/i),Up(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Jp);function $p(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var ef=function(e){function t(e,n,i,r,a){Np(this,t);var s=Bp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue($p(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function c(){Xp.unbind(window,"mousemove",l),Xp.unbind(window,"mouseup",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function h(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue($p(t,n.left,n.right,o.__min,o.__max))}function d(){Xp.unbind(window,"touchmove",h),Xp.unbind(window,"touchend",d),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),Xp.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),Xp.bind(window,"mousemove",l),Xp.bind(window,"mouseup",c),l(e)})),Xp.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(Xp.bind(window,"touchmove",h),Xp.bind(window,"touchend",d),h(e))})),Xp.addClass(s.__background,"slider"),Xp.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return Fp(t,e),Op(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Up(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Jp),tf=function(e){function t(e,n,i){Np(this,t);var r=Bp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,Xp.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),Xp.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Fp(t,e),Op(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(Vp),nf=function(e){function t(e,n){Np(this,t);var i=Bp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new zp(i.getValue()),i.__temp=new zp(0);var r=i;i.domElement=document.createElement("div"),Xp.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",Xp.bind(i.__input,"keydown",(function(e){13===e.keyCode&&d.call(this)})),Xp.bind(i.__input,"blur",d),Xp.bind(i.__selector,"mousedown",(function(){Xp.addClass(this,"drag").bind(window,"mouseup",(function(){Xp.removeClass(r.__selector,"drag")}))})),Xp.bind(i.__selector,"touchstart",(function(){Xp.addClass(this,"drag").bind(window,"touchend",(function(){Xp.removeClass(r.__selector,"drag")}))}));var a,s=document.createElement("div");function o(e){p(e),Xp.bind(window,"mousemove",p),Xp.bind(window,"touchmove",p),Xp.bind(window,"mouseup",c),Xp.bind(window,"touchend",c)}function l(e){f(e),Xp.bind(window,"mousemove",f),Xp.bind(window,"touchmove",f),Xp.bind(window,"mouseup",h),Xp.bind(window,"touchend",h)}function c(){Xp.unbind(window,"mousemove",p),Xp.unbind(window,"touchmove",p),Xp.unbind(window,"mouseup",c),Xp.unbind(window,"touchend",c),u()}function h(){Xp.unbind(window,"mousemove",f),Xp.unbind(window,"touchmove",f),Xp.unbind(window,"mouseup",h),Xp.unbind(window,"touchend",h),u()}function d(){var e=Pp(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,a=n.clientY,s=(i-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function f(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return Ep.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Ep.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Ep.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Ep.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Ep.extend(s.style,{width:"100%",height:"100%",background:"none"}),af(s,"top","rgba(0,0,0,0)","#000"),Ep.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=i.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Ep.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),Xp.bind(i.__saturation_field,"mousedown",o),Xp.bind(i.__saturation_field,"touchstart",o),Xp.bind(i.__field_knob,"mousedown",o),Xp.bind(i.__field_knob,"touchstart",o),Xp.bind(i.__hue_field,"mousedown",l),Xp.bind(i.__hue_field,"touchstart",l),i.__saturation_field.appendChild(s),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return Fp(t,e),Op(t,[{key:"updateDisplay",value:function(){var e=Pp(this.getValue());if(!1!==e){var t=!1;Ep.each(zp.COMPONENTS,(function(n){if(!Ep.isUndefined(e[n])&&!Ep.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Ep.extend(this.__color.__state,e)}Ep.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;Ep.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,af(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Ep.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(Vp),rf=["-moz-","-o-","-webkit-","-ms-",""];function af(e,t,n,i){e.style.background="",Ep.each(rf,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}var sf=function(e,t){var n=e[t];return Ep.isArray(arguments[2])||Ep.isObject(arguments[2])?new qp(e,t,arguments[2]):Ep.isNumber(n)?Ep.isNumber(arguments[2])&&Ep.isNumber(arguments[3])?Ep.isNumber(arguments[4])?new ef(e,t,arguments[2],arguments[3],arguments[4]):new ef(e,t,arguments[2],arguments[3]):Ep.isNumber(arguments[4])?new Qp(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new Qp(e,t,{min:arguments[2],max:arguments[3]}):Ep.isString(n)?new Zp(e,t):Ep.isFunction(n)?new tf(e,t,""):Ep.isBoolean(n)?new Yp(e,t):null},of=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},lf=function(){function e(){Np(this,e),this.backgroundElement=document.createElement("div"),Ep.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Xp.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Ep.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Xp.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Op(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Ep.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Xp.unbind(e.domElement,"webkitTransitionEnd",t),Xp.unbind(e.domElement,"transitionend",t),Xp.unbind(e.domElement,"oTransitionEnd",t)};Xp.bind(this.domElement,"webkitTransitionEnd",t),Xp.bind(this.domElement,"transitionend",t),Xp.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Xp.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Xp.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}(function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var cf="Default",hf=function(){try{return!!window.localStorage}catch(e){return!1}}(),df=void 0,uf=!0,pf=void 0,ff=!1,mf=[],gf=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Xp.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=Ep.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=Ep.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),Ep.isUndefined(i.load)?i.load={preset:cf}:i.preset&&(i.load.preset=i.preset),Ep.isUndefined(i.parent)&&i.hideable&&mf.push(this),i.resizable=Ep.isUndefined(i.parent)&&i.resizable,i.autoPlace&&Ep.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=hf&&"true"===localStorage.getItem(wf(0,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t1){var i=n.__li.nextElementSibling;return n.remove(),Sf(e,n.object,n.property,{before:i,factoryArgs:[Ep.toArray(arguments)]})}if(Ep.isArray(t)||Ep.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),Sf(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof ef){var i=new Qp(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Ep.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),Xp.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof Qp){var r=function(t){if(Ep.isNumber(n.__min)&&Ep.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=Sf(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(i),r&&a.listen(),a}return t};n.min=Ep.compose(r,n.min),n.max=Ep.compose(r,n.max)}else n instanceof Yp?(Xp.bind(t,"click",(function(){Xp.fakeEvent(n.__checkbox,"click")})),Xp.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof tf?(Xp.bind(t,"click",(function(){Xp.fakeEvent(n.__button,"click")})),Xp.bind(t,"mouseover",(function(){Xp.addClass(n.__button,"hover")})),Xp.bind(t,"mouseout",(function(){Xp.removeClass(n.__button,"hover")}))):n instanceof nf&&(Xp.addClass(t,"color"),n.updateDisplay=Ep.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Ep.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&xf(e.getRoot(),!0),t}),n.setValue)}(e,l,r),e.__controllers.push(r),r}function wf(e,t){return document.location.href+"."+t}function bf(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function Mf(e,t){t.style.display=e.useLocalStorage?"block":"none"}function Tf(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function i(){Xp.removeClass(e.__closeButton,gf.CLASS_DRAG),Xp.unbind(window,"mousemove",n),Xp.unbind(window,"mouseup",i)}function r(r){return r.preventDefault(),t=r.clientX,Xp.addClass(e.__closeButton,gf.CLASS_DRAG),Xp.bind(window,"mousemove",n),Xp.bind(window,"mouseup",i),!1}e.__resize_handle=document.createElement("div"),Ep.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Xp.bind(e.__resize_handle,"mousedown",r),Xp.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Ef(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Af(e,t){var n={};return Ep.each(e.__rememberedObjects,(function(i,r){var a={},s=e.__rememberedObjectIndecesToControllers[r];Ep.each(s,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[r]=a})),n}function Rf(e){0!==e.length&&of.call(window,(function(){Rf(e)})),Ep.each(e,(function(e){e.updateDisplay()}))}gf.toggleHide=function(){ff=!ff,Ep.each(mf,(function(e){e.domElement.style.display=ff?"none":""}))},gf.CLASS_AUTO_PLACE="a",gf.CLASS_AUTO_PLACE_CONTAINER="ac",gf.CLASS_MAIN="main",gf.CLASS_CONTROLLER_ROW="cr",gf.CLASS_TOO_TALL="taller-than-window",gf.CLASS_CLOSED="closed",gf.CLASS_CLOSE_BUTTON="close-button",gf.CLASS_CLOSE_TOP="close-top",gf.CLASS_CLOSE_BOTTOM="close-bottom",gf.CLASS_DRAG="drag",gf.DEFAULT_WIDTH=245,gf.TEXT_CLOSED="Close Controls",gf.TEXT_OPEN="Open Controls",gf._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||gf.toggleHide()},Xp.bind(window,"keydown",gf._keydownHandler,!1),Ep.extend(gf.prototype,{add:function(e,t){return Sf(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return Sf(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Ep.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&pf.removeChild(this.domElement);var e=this;Ep.each(this.__folders,(function(t){e.removeFolder(t)})),Xp.unbind(window,"keydown",gf._keydownHandler,!1),_f(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new gf(t);this.__folders[e]=n;var i=vf(this,n.domElement);return Xp.addClass(i,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],_f(e);var t=this;Ep.each(e.__folders,(function(t){e.removeFolder(t)})),Ep.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Xp.getOffset(e.__ul).top,n=0;Ep.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=Xp.getHeight(t))})),window.innerHeight-t-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Ep.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");Xp.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Xp.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",Xp.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",Xp.addClass(i,"button"),Xp.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",Xp.addClass(r,"button"),Xp.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Xp.addClass(a,"button"),Xp.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Ep.each(e.load.remembered,(function(t,n){bf(e,n,n===e.preset)})):bf(e,cf,!1),Xp.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Af(this)),e.folders={},Ep.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Af(this),xf(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[cf]=Af(this,!0)),this.load.remembered[e]=Af(this),this.preset=e,bf(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Ep.each(this.__controllers,(function(t){this.getRoot().load.remembered?yf(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Ep.each(this.__folders,(function(e){e.revert(e)})),e||xf(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&Rf(this.__listening)},updateDisplay:function(){Ep.each(this.__controllers,(function(e){e.updateDisplay()})),Ep.each(this.__folders,(function(e){e.updateDisplay()}))}});var Cf=gf;const Pf=(()=>{const e=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"})();console.log(Pf);const Lf="mobile"===Pf,Df=window.location.search,If=(new URLSearchParams(Df).get("id"),{}),Nf=(e,t="#000000")=>{console.log(`Status information: ${e}`);const n=document.getElementById("status-line");n&&(n.innerText=e,n.style.setProperty("color",t))},Of=e=>{let t=Vf.collectMaterials();$f.updateMaterialUI(Gf,t),Nf(`${e}`),Hf.sceneName=e.replace(/:/g,"_")},Uf=(e,t)=>{return n=void 0,i=void 0,a=function*(){let n=If[t];n||(yield Vf.loadResource(e+".glb",t,(e=>{}),((e,n)=>{n?(If[t]={scene:n,glb:!0},Of(e)):Nf(`load ${e}`,"#ff0000")})),n=If[t]),Nf(`render ${t}`,"#ff0000"),Vf.update(void 0,n.scene,n.glb),Of(t)},new((r=void 0)||(r=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function o(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(s,o)}l((a=a.apply(n,i||[])).next())}));var n,i,r,a},Ff=()=>{let e=1;switch(Hf.groundMaterial.toLocaleLowerCase()){default:e=1;break;case"parquet":e=3;break;case"pavement":e=4}Vf.setGroundMaterial(e)};const Bf=new is({canvas:three_canvas,antialias:!0,alpha:!0,preserveDrawingBuffer:!0});Bf.setPixelRatio(window.devicePixelRatio),Bf.setSize(window.innerWidth,window.innerHeight),document.body.appendChild(Bf.domElement);const zf=new class{constructor(e={}){const t=this;let n,i,r,a;const s={objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");function l(e,n,i){if(e.isCSS2DObject){$u.setFromMatrixPosition(e.matrixWorld),$u.applyMatrix4(tp);const l=!0===e.visible&&$u.z>=-1&&$u.z<=1&&!0===e.layers.test(i.layers);if(e.element.style.display=!0===l?"":"none",!0===l){e.onBeforeRender(t,n,i);const s=e.element;s.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+($u.x*r+r)+"px,"+(-$u.y*a+a)+"px)",s.parentNode!==o&&o.appendChild(s),e.onAfterRender(t,n,i)}const d={distanceToCameraSquared:(c=i,h=e,np.setFromMatrixPosition(c.matrixWorld),ip.setFromMatrixPosition(h.matrixWorld),np.distanceToSquared(ip))};s.objects.set(e,d)}var c,h;for(let t=0,r=e.children.length;t{const i=new Uint8Array(1048576);for(let e=0;e{this.skyEnvironment.changeVisibility(!1),this.backgroundEnvironment.hideBackground(),this.showEnvironment=!0},r=e.toLowerCase();if(r.endsWith(".exr"))this.environmentLoader.loadExr(e,t,!0),n();else if(r.endsWith(".hdr"))this.environmentLoader.loadHdr(e,t,!0),n();else if(r.endsWith(".envmap"))this.environmentLoader.loadEnvmap(e,t,!0),n();else if(r.endsWith(".glb")||r.endsWith(".gltf")){i(e,null);const n=yield this.loadGLTF(t);i(e,n)}}catch(e){console.log(e)}}))}createControls(){var e;null!==(e=this.controls)&&void 0!==e||(this.controls=new eu(this.renderer,this.camera))}changeLightControls(e){var t;e&&!this.transformControls&&(this.transformControls=null===(t=this.controls)||void 0===t?void 0:t.addTransformControl(this.lightSources.getLightSources()[0],this.scene)),this.transformControls&&(this.transformControls.visible=e)}setEnvironment(){this.environmentLoader.loadDefaultEnvironment(!0,(()=>new cp({type:lp})),"room environment"),this.environmentLoader.loadDefaultEnvironment(!1,(()=>new cp({type:op})),"front light environment"),this.environmentLoader.loadEnvmap("test64.envmap",_p,!1)}updateSceneDependencies(){this.sceneRenderer.bakedGroundContactShadow.needsUpdate=!0,this.updateBounds()}updateBounds(){this.sceneRenderer.updateBounds(this.sceneBounds,this.scaleShadowAndAo)}setGroundMaterial(e){this.groundMaterialType!==e&&(this.groundMaterialType=e,this.updateGround(void 0,hc(this.groundMaterialType)),this.sceneRenderer.clearCache())}updateGround(e,t){this.groundMesh||(this.groundMesh=new ti,this.groundMesh.name="groundMesh",this.groundMesh.userData.isFloor=!0,this.groundMesh.receiveShadow=!0,this.sceneRenderer.groundGroup.add(this.groundMesh)),e&&(this.groundMesh.geometry=e),t&&(t.depthWrite=!1,t.polygonOffset=!0,t.polygonOffsetFactor=4,t.polygonOffsetUnits=4,t.needsUpdate=!0,this.groundMesh.material=t,this.groundMesh.userData.isFloor=!0)}update(e,t,n){t&&this.setNewTurntableGroup(t,null!=n&&n),e&&this.properties.rotate!==(null==e?void 0:e.rotate)&&(this.properties.rotate=null==e?void 0:e.rotate,0===this.properties.rotate&&(this.turnTableGroup.rotation.y=0)),e&&this.properties.dimensions!==(null==e?void 0:e.dimensions)&&(this.properties.dimensions=null==e?void 0:e.dimensions,this.updateDimensions()),e&&this.properties.randomOrientation!==(null==e?void 0:e.randomOrientation)&&(this.properties.randomOrientation=null==e?void 0:e.randomOrientation)}updateDimensions(){if(this.properties.dimensions){if(0===this.dimensioningArrows.length)for(let e=0;e<3;++e){const e=new rp(new Je,new Je,{color:0,arrowPixelWidth:10,arrowPixelHeight:15,shaftPixelWidth:3,shaftPixelOffset:1,labelClass:"label",deviceRatio:window.devicePixelRatio});this.dimensioningArrows.push(e),this.dimensioningArrowScene.add(e)}const e=this.sceneRenderer.boundingVolume.bounds,t=this.sceneRenderer.boundingVolume.size,n=.2*Math.min(t.x,t.y,t.z);this.dimensioningArrows[0].setPosition(new Je(e.min.x,e.min.y,e.max.z+n),new Je(e.max.x,e.min.y,e.max.z+n)),this.dimensioningArrows[1].setPosition(new Je(e.min.x-n,e.min.y,e.max.z+n),new Je(e.min.x-n,e.max.y,e.max.z+n)),this.dimensioningArrows[2].setPosition(new Je(e.min.x-n,e.min.y,e.max.z),new Je(e.min.x-n,e.min.y,e.min.z))}else this.dimensioningArrows.forEach((e=>e.setLabel("")))}collectMaterials(){const e=[];return this.scene.traverse((t=>{if(t instanceof ti&&t.name.length>0){const n=t.material;n&&e.push({materialId:t.name,material:n})}else if(t instanceof ti&&t.material.name.length>0){const n=t.material;if(n){const i=t.material.name;-1===e.findIndex((e=>e.materialId===i))&&e.push({materialId:i,material:n})}}})),e}updateMaterialProperties(e,t){this.properties.materialNoise!==e.materialNoise&&(this.properties.materialNoise=e.materialNoise,t.forEach((e=>{const t=e.material;t.userData&&"ormMap"in t.userData||(t.roughnessMap=this.properties.materialNoise?this.noiseTexture:null,t.metalnessMap=this.properties.materialNoise?this.noiseTexture:null,t.needsUpdate=!0)})))}resize(e,t){var n;this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.sceneRenderer.setSize(e,t),null===(n=this.css2Renderer)||void 0===n||n.setSize(e,t)}animate(e){this.properties.rotate>0&&(this.turnTableGroup.rotation.y+=2*Math.PI*e*.001*this.properties.rotate)}prepareRender(e){var t,n;const i=this.environmentLoader.setEnvironment(this.scene,{showEnvironment:this.showEnvironment,environmentRotation:this.environmentRotation,environmentIntensity:this.environmentIntensity});if(i){null===(t=this.groundProjectionSkybox)||void 0===t||t.removeFromParent(),this.groundProjectionSkybox=null;const e=null===(n=this.environmentLoader.currentEnvironment)||void 0===n?void 0:n.equirectangularTexture;this.scene.userData.shadowFromEnvironment=!0,e&&(this.lightSources.currentLightSourceDefinition=Dl.noLightSources,this.lightSources.updateLightSources(),this.createGroundProjectionSkybox&&(this.groundProjectionSkybox=new vp(e),this.groundProjectionSkybox.scale.setScalar(this.groundProjectionSkyboxDistance),this.groundProjectionSkybox.name="skybox",this.scene.add(this.groundProjectionSkybox)))}const r=this.createGroundProjectionSkybox&&this.groundProjectionSkybox?2*this.groundProjectionSkyboxDistance:void 0;if(this.sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(this.camera,r),i&&this.updateSceneDependencies(),this.sceneRenderer.outlineRenderer.parameters.enabled){this.raycaster.setFromCamera(e,this.camera);const t=this.raycaster.intersectObject(this.turnTableGroup,!0);let n=t.length>0?t[0].object:void 0;this.sceneRenderer.selectObjects(n?[n]:[])}}render(e=!0){var t,n;e&&(null===(t=this.controls)||void 0===t||t.update()),this.backgroundEnvironment.update(this.sceneRenderer.width,this.sceneRenderer.height,this.camera),this.sceneRenderer.render(this.scene,this.camera),this.properties.dimensions&&(this.dimensioningArrows.forEach((e=>{e.arrowNeedsUpdate=!0})),this.renderer.autoClear=!1,this.renderer.render(this.dimensioningArrowScene,this.camera),null===(n=this.css2Renderer)||void 0===n||n.render(this.dimensioningArrowScene,this.camera),this.renderer.autoClear=!0)}loadGLTF(e){return xp(this,void 0,void 0,(function*(){const t=new Mh;(new Sh).setDecoderPath("three/examples/jsm/libs/draco/");const n=yield t.loadAsync(e);return this.updateGLTFScene(n,(e=>{if(e.isMesh){const t=e.material;t instanceof yo&&!1===t.transparent&&(e.castShadow=!0,e.receiveShadow=!0)}})),this.setNewTurntableGroup(n.scene,!0),n.scene}))}updateGLTFScene(e,t){e.scene.traverse((e=>{e instanceof ti&&(t(e),e.material instanceof yo&&(e.material.envMapIntensity=1,e.material.needsUpdate=!0))}))}setNewTurntableGroup(e,t){this.turnTableGroup.clear(),this.scaleShadowAndAo=t,this.setInitialObjectPosition(e),this.setInitialCameraPositionAndRotation(),this.sceneRenderer.environmentLights||this.lightSources.setLightSourcesDistances(this.sceneRenderer.boundingVolume,t),this.sceneRenderer.forceShadowUpdates(!0),this.updateSceneDependencies()}setInitialObjectPosition(e){e.updateMatrixWorld(),this.sceneBounds.setFromObject(e);const t=this.sceneBounds.getSize(new Je),n=this.sceneBounds.getCenter(new Je);e.applyMatrix4((new At).makeTranslation(-n.x,-this.sceneBounds.min.y,-n.z)),this.sceneBounds.translate(new Je(-n.x,-this.sceneBounds.min.y-t.y/2,-n.z));const i=-t.y/2;this.turnTableGroup.position.y=i,this.turnTableGroup.add(e),this.turnTableGroup.updateMatrixWorld(),this.sceneRenderer.groundLevel=i}setInitialCameraPositionAndRotation(){const e=new Je(-1.5,.8,2.5).normalize();if(this.properties.randomOrientation){const t=4*Math.random()-2,n=.8*Math.random()+.4;e.set(t,n,2.5).normalize()}this.camera.position.copy(e),this.camera.lookAt(new Je(0,0,0)),this.camera.updateMatrixWorld();const t=(new et).setFromObject(this.turnTableGroup).applyMatrix4(this.camera.matrixWorldInverse),n=this.camera.fov*Math.PI/180/2,i=this.camera.aspect,r=Math.max(-t.min.x/i,t.max.x/i,-t.min.y,t.max.y)/Math.tan(n)+t.max.z+1;this.camera.position.copy(e.multiplyScalar(r)),this.camera.lookAt(new Je(0,0,0)),this.camera.updateMatrixWorld()}constructLoadingGeometry(e){let t=[];if(1===e){const e=[];for(let t=0;t<=230;t+=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)+1})}e.push({x:0,y:0});for(let t=60;t>=-180;t-=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)-1})}const n=.6,i=2.5*n,r=new io(e.map((e=>new Je(e.x,e.y+2+i,0)))),a=new _o(r,64,n,16,!1),s=new go(n,32,16);s.translate(-1,3+i,0);const o=new go(n,32,16);o.translate(1,1+i,0);const l=new go(n,32,16),c=new So({color:14352384,side:2});t=[{geometry:a,material:c,materialId:"",environment:!1},{geometry:s,material:c,materialId:"",environment:!1},{geometry:o,material:c,materialId:"",environment:!1},{geometry:l,material:c,materialId:"",environment:!1}]}else{const e=(()=>{const e=new yo({side:2});return tc((t=>e.map=t),lc,new gn(.9,.9,.9)),e})();t=[{geometry:new ii,material:e,materialId:"",environment:!1}]}return(e=>{const t=new Ja;return e.forEach((e=>{const n=new ti(e.geometry,e.material);e.transform&&n.applyMatrix4(e.transform),n.castShadow=!e.environment,n.receiveShadow=!0,t.add(n)})),t})(t)}}(Bf,zf);Vf.sceneRenderer.setQualityLevel(Lf?Ku.LOW:Ku.HIGHEST),Vf.createControls(),Vf.setEnvironment(),Vf.updateSceneDependencies(),Ff();const Gf=new Cf,Wf=Object.assign({},...t.map((e=>({[e.name]:e.url})))),jf=Gf.add(Hf,"glb",Wf).onChange((e=>{if(""!==e){const n=t.findIndex((t=>t.url===e)),i=n>=0?t[n].name:e;Uf(i,e)}}));Gf.add(Hf,"randomOrientation").onChange((()=>Vf.update(Hf))),Gf.add(Hf,"dimensions").onChange((()=>Vf.update(Hf))),Gf.add(Hf,"groundMaterial",{"only shadow":"onlyshadow",parquet:"parquet",pavement:"pavement"}).onChange((()=>Ff()));const Xf=Gf.addFolder("environment"),Yf=Xf.add(Vf,"showEnvironment").onChange((e=>{e&&(Zf.hideSky(),Jf.hideBackground())}));Xf.add(Vf,"environmentRotation",0,2*Math.PI,.01).onChange((e=>{var t;(null===(t=Vf.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(Vf.scene.userData.environmentDefinition.rotation=e)})),Xf.add(Vf,"environmentIntensity",0,5,.01).onChange((e=>{var t;(null===(t=Vf.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(Vf.scene.userData.environmentDefinition.intensity=e)}));const qf=Xf.addFolder("sky"),Zf=new class{constructor(e){this.skyEnvironment=e}hideSky(){var e,t;null===(e=this.showSkyController)||void 0===e||e.setValue(!1),null===(t=this.showSkyController)||void 0===t||t.updateDisplay()}addGUI(e,t){this.showSkyController=e.add(this.skyEnvironment.parameters,"visible").onChange((()=>{this.skyEnvironment.updateSky(),t&&t(this.skyEnvironment)}))}}(Vf.skyEnvironment);Zf.addGUI(qf,(e=>{e.parameters.visible&&(Yf.setValue(!1),Yf.updateDisplay(),Jf.hideBackground())}));const Kf=Xf.addFolder("background"),Jf=new class{constructor(e){this._backgroundEnvironment=e}hideBackground(){var e,t;null===(e=this._backgroundTypeController)||void 0===e||e.setValue("None"),null===(t=this._backgroundTypeController)||void 0===t||t.updateDisplay()}addGUI(e,t){const n={backgroundType:""},i=new Map([["None",rh.None],["Grid Paper",rh.GridPaper],["Concrete",rh.Concrete],["Marble",rh.Marble],["Granite",rh.Granite],["Vorocracks Marble",rh.VorocracksMarble],["Kraft",rh.Kraft],["Line (slow)",rh.Line],["Test",rh.Test]]),r=[];i.forEach(((e,t)=>{r.push(t),this._backgroundEnvironment.parameters.backgroundType===e&&(n.backgroundType=t)})),e.add(n,"backgroundType",r).onChange((e=>{var n;i.has(e)&&(this._backgroundEnvironment.parameters.backgroundType=null!==(n=i.get(e))&&void 0!==n?n:rh.None,this._backgroundEnvironment.updateBackground(),t&&t(this._backgroundEnvironment))}))}}(Vf.backgroundEnvironment);Jf.addGUI(Kf,(e=>{e.parameters.isSet&&(Yf.setValue(!1),Yf.updateDisplay(),Zf.hideSky())})),Vf.environmentLoader.addGUI(Xf);const Qf=new class{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const i=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(i,t);const r=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(r,t);const a=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(a,t);const s=e.addFolder("Outline");this._addOutlineGUI(s,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",K],["SRGBColorSpace",Z]]),i=[];n.forEach(((e,t)=>{i.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)})),e.add(this._sceneRenderer,"outputColorSpace",i).onChange((e=>{var i;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(i=n.get(e))&&void 0!==i?i:Z,t())}));const r=new Map([["NoToneMapping",h],["LinearToneMapping",d],["ReinhardToneMapping",u],["CineonToneMapping",p],["ACESFilmicToneMapping",f]]),a=[];r.forEach(((e,t)=>{a.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)})),e.add(this._sceneRenderer,"toneMapping",a).onChange((e=>{var n;r.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=r.get(e))&&void 0!==n?n:h,t())}))}_addDebugGUI(e,t){const n=new Map([["HIGHEST",Ku.HIGHEST],["HIGH",Ku.HIGH],["MEDIUM",Ku.MEDIUM],["LOW",Ku.LOW]]),i=[];n.forEach(((e,t)=>i.push(t))),e.add(this,"_qualityLevel",i).onChange((e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:Ku.HIGHEST)})),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow Monte Carlo":"shadow","shadow blur":"shadowblur","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","ground reflection":"groundreflection","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange((()=>t()))}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadow.shadowConfiguration,i=[];n.types.forEach(((e,t)=>{i.push(t)}));const r=()=>{this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",i).onChange((e=>{this._sceneRenderer.screenSpaceShadow.switchType(e)&&(a.object=n.currentConfiguration,s.object=n.currentConfiguration,o.object=n.currentConfiguration,a.updateDisplay(),s.updateDisplay(),o.updateDisplay(),r())}));const a=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange((()=>r())),s=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange((()=>r())),o=e.add(n.currentConfiguration,"radius",0,100).onChange((()=>r()))}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.gBufferRenderTarget.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.shadowAndAoRenderTargets.parametersNeedsUpdate=!0,t()},i=this._sceneRenderer.shadowAndAoPass.parameters,r=i.shadow,a=this._sceneRenderer.screenSpaceShadow.parameters,s=i.ao,o=i.poissonDenoise;e.add(i,"enabled").onChange((()=>n()));const l=new Map([["none",null],["SSAO",0],["SAO",1],["N8AO",2],["HBAO",3],["GTAO",4]]),c=Array.from(l.keys());l.forEach(((e,t)=>{e===s.algorithm&&(this._ambientOcclusionType=t)})),e.add(i,"aoIntensity",0,1).onChange((()=>{n()})),e.add(i,"aoOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowIntensity",0,1).onChange((()=>n())),e.add(i,"alwaysUpdate").onChange((()=>n())),e.add(i,"progressiveDenoiseIterations",0,3,1).onChange((()=>n()));const h=e.addFolder("Shadow and Monte Carlo integration");h.add(a,"maximumNumberOfLightSources",-1,10,1).onChange((()=>n())),h.add(a,"enableGroundBoundary").onChange((()=>n())),h.add(a,"directionalDependency",0,1,.01).onChange((()=>n())),h.add(a,"directionalExponent",0,2,.01).onChange((()=>n())),h.add(a,"groundBoundary",0,1,.01).onChange((()=>n())),h.add(a,"fadeOutDistance",0,5,.01).onChange((()=>n())),h.add(a,"fadeOutBlur",0,20,1).onChange((()=>n())),h.add(r,"shadowRadius",.001,.5).onChange((()=>n()));const d=e.addFolder("AO");d.add(this,"_ambientOcclusionType",c).onChange((e=>{if(l.has(e)){const t=l.get(e);s.algorithm=void 0!==t?t:0,n()}})),d.add(s,"samples",1,64,1).onChange((()=>n())),d.add(s,"radius",.01,2,.01).onChange((()=>n())),d.add(s,"distanceExponent",.1,4,.1).onChange((()=>n())),d.add(s,"thickness",.01,2,.01).onChange((()=>n())),d.add(s,"distanceFallOff",0,1).onChange((()=>n())),d.add(s,"scale",.01,2,.01).onChange((()=>n())),d.add(s,"bias",1e-4,.01,1e-4).onChange((()=>n())),d.add(s,"screenSpaceRadius").onChange((()=>n()));const u=e.addFolder("Possion Denoise");u.add(o,"iterations",0,4,1).onChange((()=>n())),u.add(o,"samples",0,32,1).onChange((()=>n())),u.add(o,"rings",0,16,.125).onChange((()=>n())),u.add(o,"radiusExponent",.1,4,.01).onChange((()=>n())),u.add(o,"radius",0,50,1).onChange((()=>n())),u.add(o,"lumaPhi",0,20,.001).onChange((()=>n())),u.add(o,"depthPhi",0,20,.001).onChange((()=>n())),u.add(o,"normalPhi",0,20,.001).onChange((()=>n()))}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange((()=>t())),e.add(n,"fadeOutDistance",0,4).onChange((()=>t())),e.add(n,"fadeOutExponent",.1,10).onChange((()=>t())),e.add(n,"brightness",0,2).onChange((()=>t())),e.add(n,"blurHorizontal",0,10).onChange((()=>t())),e.add(n,"blurVertical",0,10).onChange((()=>t()))}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadow.applyParameters(),t()},i=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(i,"enabled"),e.add(i,"cameraHelper").onChange((()=>n())),e.add(i,"alwaysUpdate"),e.add(i,"fadeIn"),e.add(i,"blurMin",0,.2,.001).onChange((()=>n())),e.add(i,"blurMax",0,.5,.01).onChange((()=>n())),e.add(i,"fadeoutFalloff",0,1,.01).onChange((()=>n())),e.add(i,"fadeoutBias",0,.5).onChange((()=>n())),e.add(i,"opacity",0,1,.01).onChange((()=>n())),e.add(i,"maximumPlaneSize",0,50,1).onChange((()=>n())),e.add(i,"cameraFar",.1,10,.1).onChange((()=>n()))}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},i=this._sceneRenderer.outlineRenderer.parameters;e.add(i,"enabled"),e.add(i,"edgeStrength",.5,20).onChange((()=>n())),e.add(i,"edgeGlow",0,20).onChange((()=>n())),e.add(i,"edgeThickness",.5,20).onChange((()=>n())),e.add(i,"pulsePeriod",0,5).onChange((()=>n())),e.addColor(i,"visibleEdgeColor").onChange((()=>n())),e.addColor(i,"hiddenEdgeColor").onChange((()=>n()))}}(Vf.sceneRenderer);Qf.addGUI(Gf,(()=>{}));const $f=new yp,em=Gf.addFolder("Light"),tm=new class{constructor(e){this.lightColors=[],this.lightSourceFolders=[],this.lights="none",this.lightSources=e}addGUI(e,t,n){e.add(this.lightSources,"lightControls").onChange(t),e.add(this,"lights",["none","default","fife"]).onChange((e=>{switch(e){default:case"none":this.lightSources.currentLightSourceDefinition=Dl.noLightSources;break;case"default":this.lightSources.currentLightSourceDefinition=Dl.defaultLightSources;break;case"fife":this.lightSources.currentLightSourceDefinition=Dl.fifeLightSources}this.lightSources.updateLightSources(),this.updateGUI(),n()})),this.lightGUI=e,this.updateGUI()}updateGUI(){if(!this.lightGUI)return;const e=this.lightGUI;this.lightSourceFolders.forEach((t=>e.removeFolder(t))),this.lightSourceFolders=[],this.lightColors=[],this.lightSources.getLightSources().forEach((t=>{if(t instanceof pl){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Ambient Light");this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(5).step(.1),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new gn(e)))}})),this.lightSources.getLightSources().forEach((t=>{var n;if(t instanceof ul){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Directional Light "+(this.lightColors.length-1));this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(10).step(.1),n.add(t,"castShadow"),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new gn(e)))}else if(t instanceof fl){this.lightColors.push({color:t.color.getHex()});const i=e.addFolder("Rect area Light "+(this.lightColors.length-1));this.lightSourceFolders.push(i);const r=null===(n=this.lightSources.sceneRenderer)||void 0===n?void 0:n.screenSpaceShadow.findShadowLightSource(t);i.add(t,"visible"),i.add(t,"intensity").min(0).max(200).step(1),r&&i.add(r,"castShadow"),i.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new gn(e)))}}))}}(Vf.getLightSources());tm.addGUI(em,(()=>e=>Vf.changeLightControls(e)),(()=>Vf.updateSceneDependencies())),window.addEventListener("resize",(()=>{const e=(void 0,window.innerWidth),t=(void 0,window.innerHeight);Vf.resize(e,t)}),!1);const nm=new be;Bf.domElement.addEventListener("pointermove",(e=>{!1!==e.isPrimary&&(nm.x=e.clientX/window.innerWidth*2-1,nm.y=-e.clientY/window.innerHeight*2+1)})),((e,t,n)=>{const i=document.getElementById("holder");i&&(i.ondragover=function(){return this.className="hover",!1},i.ondragend=function(){return this.className="",!1},i.ondrop=function(e){this.className="",e.preventDefault();const t=e.dataTransfer.files[0],n=new FileReader;n.onload=e=>((e,t)=>{((e,t)=>{const n=If[e];n?(Nf(`render ${e}`,"#ff0000"),Vf.update(void 0,n.scene,n.glb),Of(e)):Vf.loadResource(e,t,(e=>{}),((t,n)=>{n?(If[e]={scene:n,glb:!0},Of(t),(e=>{Wf.push(e);let t="";Wf.forEach((e=>{t+=""})),jf.domElement.children[0].innerHTML=t,jf.setValue(e),jf.updateDisplay()})(e)):Nf(`load ${t}`,"#ff0000")}))})(e.name,t.target.result)})(t,e),n.readAsDataURL(t)})})();const im=document.createElement("a"),rm=e=>{const t=Bf.domElement.toDataURL();im.href=t,im.download=e,im.click()},am=(e,t)=>{const n=Vf.sceneRenderer.debugOutput;Vf.sceneRenderer.debugOutput=e,Vf.prepareRender(new be),Vf.render(!1),rm(t),Vf.sceneRenderer.debugOutput=n},sm=document.getElementById("save-button");sm&&(sm.onclick=()=>(()=>{try{rm(Hf.sceneName+".png")}catch(e){console.log(e)}})());const om=document.getElementById("save-g-buffer-button");let lm,cm;om&&(om.onclick=()=>(()=>{try{am("color",Hf.sceneName+"_color.png"),am("g-normal",Hf.sceneName+"_normal.png"),am("g-depth",Hf.sceneName+"_depth.png")}catch(e){console.log(e)}})());const hm=e=>{void 0===lm&&(lm=e),void 0===cm&&(cm=e);const t=e-cm;cm=e,Vf.animate(t),dm(),requestAnimationFrame(hm)},dm=()=>{Vf.prepareRender(nm),Vf.render(),kf.update()};(e=>{const n=t.findIndex((e=>"BrainStem"===e.name));if(n>=0){const e=t[n];Uf(e.name,e.url)}})(),requestAnimationFrame(hm)})(); \ No newline at end of file +(()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var n=e.g.document;if(!t&&n&&(n.currentScript&&(t=n.currentScript.src),!t)){var i=n.getElementsByTagName("script");if(i.length)for(var r=i.length-1;r>-1&&!t;)t=i[r--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})();const t=[{name:"BrainStem",url:"./BrainStem.glb"},{name:"DamagedHelmet",url:"./DamagedHelmet.glb"}],n="160",i=1,r=2,a=3,s=100,o=0,l=1,c=2,h=0,d=1,u=2,p=3,f=4,m=5,g=6,v="attached",_=301,x=302,y=306,S=1e3,w=1001,b=1002,M=1003,T=1004,E=1005,A=1006,R=1008,C=1009,P=1012,L=1014,D=1015,I=1016,N=1020,O=1023,U=1026,F=1027,B=1028,z=1030,k=33776,H=33777,V=33778,G=33779,W=36492,j=2300,X=2301,Y=2302,q=3001,Z="",K="srgb",J="srgb-linear",Q="display-p3",$="display-p3-linear",ee="linear",te="srgb",ne="rec709",ie="p3",re=7680,ae=35044,se="300 es",oe=1035,le=2e3,ce=2001;class he{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.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 n=t.slice(0);for(let t=0,i=n.length;t>8&255]+de[e>>16&255]+de[e>>24&255]+"-"+de[255&t]+de[t>>8&255]+"-"+de[t>>16&15|64]+de[t>>24&255]+"-"+de[63&n|128]+de[n>>8&255]+"-"+de[n>>16&255]+de[n>>24&255]+de[255&i]+de[i>>8&255]+de[i>>16&255]+de[i>>24&255]).toLowerCase()}function ge(e,t,n){return Math.max(t,Math.min(n,e))}function ve(e,t){return(e%t+t)%t}function _e(e,t,n){return(1-n)*e+n*t}function xe(e){return 0==(e&e-1)&&0!==e}function ye(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Se(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 we(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 be={DEG2RAD:pe,RAD2DEG:fe,generateUUID:me,clamp:ge,euclideanModulo:ve,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:_e,damp:function(e,t,n,i){return _e(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(ve(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(ue=e);let t=ue+=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(e){return e*pe},radToDeg:function(e){return e*fe},isPowerOfTwo:xe,ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:ye,setQuaternionFromProperEuler:function(e,t,n,i,r){const a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),c=a((t+i)/2),h=s((t+i)/2),d=a((t-i)/2),u=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*h,l*d,l*u,o*c);break;case"YZY":e.set(l*u,o*h,l*d,o*c);break;case"ZXZ":e.set(l*d,l*u,o*h,o*c);break;case"XZX":e.set(o*h,l*f,l*p,o*c);break;case"YXY":e.set(l*p,o*h,l*f,o*c);break;case"ZYZ":e.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:we,denormalize:Se};class Me{constructor(e=0,t=0){Me.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Te{constructor(e,t,n,i,r,a,s,o,l){Te.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=s,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],c=n[4],h=n[7],d=n[2],u=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],x=i[7],y=i[2],S=i[5],w=i[8];return r[0]=a*f+s*v+o*y,r[3]=a*m+s*_+o*S,r[6]=a*g+s*x+o*w,r[1]=l*f+c*v+h*y,r[4]=l*m+c*_+h*S,r[7]=l*g+c*x+h*w,r[2]=d*f+u*v+p*y,r[5]=d*m+u*_+p*S,r[8]=d*g+u*x+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8];return t*a*c-t*s*l-n*r*c+n*s*o+i*r*l-i*a*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=c*a-s*l,d=s*o-c*r,u=l*r-a*o,p=t*h+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=h*f,e[1]=(i*l-c*n)*f,e[2]=(s*n-i*a)*f,e[3]=d*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=u*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(Ee.makeScale(e,t)),this}rotate(e){return this.premultiply(Ee.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ee.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Ee=new Te;function Ae(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Re(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function Ce(){const e=Re("canvas");return e.style.display="block",e}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;const Pe={};function Le(e){e in Pe||(Pe[e]=!0,console.warn(e))}const De=(new Te).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ie=(new Te).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ne={[J]:{transfer:ee,primaries:ne,toReference:e=>e,fromReference:e=>e},[K]:{transfer:te,primaries:ne,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[$]:{transfer:ee,primaries:ie,toReference:e=>e.applyMatrix3(Ie),fromReference:e=>e.applyMatrix3(De)},[Q]:{transfer:te,primaries:ie,toReference:e=>e.convertSRGBToLinear().applyMatrix3(Ie),fromReference:e=>e.applyMatrix3(De).convertLinearToSRGB()}},Oe=new Set([J,$]),Ue={enabled:!0,_workingColorSpace:J,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!Oe.has(e))throw new Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const i=Ne[t].toReference;return(0,Ne[n].fromReference)(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return Ne[e].primaries},getTransfer:function(e){return e===Z?ee:Ne[e].transfer}};function Fe(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Be(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let ze;class ke{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===ze&&(ze=Re("canvas")),ze.width=e.width,ze.height=e.height;const n=ze.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ze}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=Re("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}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 S:e.x=e.x-Math.floor(e.x);break;case w:e.x=e.x<0?0:1;break;case b: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 S:e.y=e.y-Math.floor(e.y);break;case w:e.y=e.y<0?0:1;break;case b: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 Le("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===K?q:3e3}set encoding(e){Le("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===q?K:Z}}je.DEFAULT_IMAGE=null,je.DEFAULT_MAPPING=300,je.DEFAULT_ANISOTROPY=1;class Xe{constructor(e=0,t=0,n=0,i=1){Xe.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=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,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+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,n,i,r;const a=.01,s=.1,o=e.elements,l=o[0],c=o[4],h=o[8],d=o[1],u=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-d)o&&e>v?ev?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}const r=s*n;if(o=o*e+d*r,l=l*e+u*r,c=c*e+p*r,h=h*e+f*r,e===1-s){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const s=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[a],d=r[a+1],u=r[a+2],p=r[a+3];return e[t]=s*p+c*h+o*u-l*d,e[t+1]=o*p+c*d+l*h-s*u,e[t+2]=l*p+c*u+s*d-o*h,e[t+3]=c*p-s*h-o*d-l*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),c=s(i/2),h=s(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"YXZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"ZXY":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"ZYX":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"YZX":this._x=d*c*h+l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h-d*u*p;break;case"XZY":this._x=d*c*h-l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],c=t[6],h=t[10],d=n+s+h;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>h){const e=2*Math.sqrt(1+n-s-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>h){const e=2*Math.sqrt(1+s-n-h);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ge(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 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 n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+a*s+i*l-r*o,this._y=i*c+a*o+r*s-n*l,this._z=r*c+a*l+n*o-i*s,this._w=a*c-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let s=a*e._w+n*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const o=1-s*s;if(o<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,s),h=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Qe{constructor(e=0,t=0,n=0){Qe.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(et.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(et.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),c=2*(s*t-r*i),h=2*(r*n-a*t);return this.x=t+o*l+a*h-s*c,this.y=n+o*c+s*l-r*h,this.z=i+o*h+r*c-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return $e.copy(this).projectOnVector(e),this.sub($e)}reflect(e){return this.sub($e.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 n=this.dot(e)/t;return Math.acos(ge(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,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,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const $e=new Qe,et=new Je;class tt{constructor(e=new Qe(1/0,1/0,1/0),t=new Qe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,it),it.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(dt),ut.subVectors(this.max,dt),at.subVectors(e.a,dt),st.subVectors(e.b,dt),ot.subVectors(e.c,dt),lt.subVectors(st,at),ct.subVectors(ot,st),ht.subVectors(at,ot);let t=[0,-lt.z,lt.y,0,-ct.z,ct.y,0,-ht.z,ht.y,lt.z,0,-lt.x,ct.z,0,-ct.x,ht.z,0,-ht.x,-lt.y,lt.x,0,-ct.y,ct.x,0,-ht.y,ht.x,0];return!!mt(t,at,st,ot,ut)&&(t=[1,0,0,0,1,0,0,0,1],!!mt(t,at,st,ot,ut)&&(pt.crossVectors(lt,ct),t=[pt.x,pt.y,pt.z],mt(t,at,st,ot,ut)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,it).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(it).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()||(nt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),nt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),nt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),nt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),nt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),nt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),nt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),nt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(nt)),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 nt=[new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe,new Qe],it=new Qe,rt=new tt,at=new Qe,st=new Qe,ot=new Qe,lt=new Qe,ct=new Qe,ht=new Qe,dt=new Qe,ut=new Qe,pt=new Qe,ft=new Qe;function mt(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){ft.fromArray(e,a);const s=r.x*Math.abs(ft.x)+r.y*Math.abs(ft.y)+r.z*Math.abs(ft.z),o=t.dot(ft),l=n.dot(ft),c=i.dot(ft);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>s)return!1}return!0}const gt=new tt,vt=new Qe,_t=new Qe;class xt{constructor(e=new Qe,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):gt.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.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;vt.subVectors(e,this.center);const t=vt.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(vt,n/e),this.radius+=n}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(vt.copy(e.center).add(_t)),this.expandByPoint(vt.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 yt=new Qe,St=new Qe,wt=new Qe,bt=new Qe,Mt=new Qe,Tt=new Qe,Et=new Qe;class At{constructor(e=new Qe,t=new Qe(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,yt)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=yt.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(yt.copy(this.origin).addScaledVector(this.direction,t),yt.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){St.copy(e).add(t).multiplyScalar(.5),wt.copy(t).sub(e).normalize(),bt.copy(this.origin).sub(St);const r=.5*e.distanceTo(t),a=-this.direction.dot(wt),s=bt.dot(this.direction),o=-bt.dot(wt),l=bt.lengthSq(),c=Math.abs(1-a*a);let h,d,u,p;if(c>0)if(h=a*o-s,d=a*s-o,p=r*c,h>=0)if(d>=-p)if(d<=p){const e=1/c;h*=e,d*=e,u=h*(h+a*d+2*s)+d*(a*h+d+2*o)+l}else d=r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d=-r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d<=-p?(h=Math.max(0,-(-a*r+s)),d=h>0?-r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l):d<=p?(h=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(h=Math.max(0,-(a*r+s)),d=h>0?r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l);else d=a>0?-r:r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(St).addScaledVector(wt,d),u}intersectSphere(e,t){yt.subVectors(e.center,this.origin);const n=yt.dot(this.direction),i=yt.dot(yt)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),c>=0?(r=(e.min.y-d.y)*c,a=(e.max.y-d.y)*c):(r=(e.max.y-d.y)*c,a=(e.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-d.z)*h,o=(e.max.z-d.z)*h):(s=(e.max.z-d.z)*h,o=(e.min.z-d.z)*h),n>o||s>i?null:((s>n||n!=n)&&(n=s),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,yt)}intersectTriangle(e,t,n,i,r){Mt.subVectors(t,e),Tt.subVectors(n,e),Et.crossVectors(Mt,Tt);let a,s=this.direction.dot(Et);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}bt.subVectors(this.origin,e);const o=a*this.direction.dot(Tt.crossVectors(bt,Tt));if(o<0)return null;const l=a*this.direction.dot(Mt.cross(bt));if(l<0)return null;if(o+l>s)return null;const c=-a*bt.dot(Et);return c<0?null:this.at(c/s,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 Rt{constructor(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){Rt.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,n,i,r,a,s,o,l,c,h,d,u,p,f,m)}set(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=d,g[3]=u,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Rt).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Ct.setFromMatrixColumn(e,0).length(),r=1/Ct.setFromMatrixColumn(e,1).length(),a=1/Ct.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*h,t[5]=a*c,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*s,t[4]=-a*h,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*c,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=a*c,t[9]=-s*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=a*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=s*c,t[10]=r*h+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(Lt,e,Dt)}lookAt(e,t,n){const i=this.elements;return Ot.subVectors(e,t),0===Ot.lengthSq()&&(Ot.z=1),Ot.normalize(),It.crossVectors(n,Ot),0===It.lengthSq()&&(1===Math.abs(n.z)?Ot.x+=1e-4:Ot.z+=1e-4,Ot.normalize(),It.crossVectors(n,Ot)),It.normalize(),Nt.crossVectors(Ot,It),i[0]=It.x,i[4]=Nt.x,i[8]=Ot.x,i[1]=It.y,i[5]=Nt.y,i[9]=Ot.y,i[2]=It.z,i[6]=Nt.z,i[10]=Ot.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],c=n[1],h=n[5],d=n[9],u=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],x=n[11],y=n[15],S=i[0],w=i[4],b=i[8],M=i[12],T=i[1],E=i[5],A=i[9],R=i[13],C=i[2],P=i[6],L=i[10],D=i[14],I=i[3],N=i[7],O=i[11],U=i[15];return r[0]=a*S+s*T+o*C+l*I,r[4]=a*w+s*E+o*P+l*N,r[8]=a*b+s*A+o*L+l*O,r[12]=a*M+s*R+o*D+l*U,r[1]=c*S+h*T+d*C+u*I,r[5]=c*w+h*E+d*P+u*N,r[9]=c*b+h*A+d*L+u*O,r[13]=c*M+h*R+d*D+u*U,r[2]=p*S+f*T+m*C+g*I,r[6]=p*w+f*E+m*P+g*N,r[10]=p*b+f*A+m*L+g*O,r[14]=p*M+f*R+m*D+g*U,r[3]=v*S+_*T+x*C+y*I,r[7]=v*w+_*E+x*P+y*N,r[11]=v*b+_*A+x*L+y*O,r[15]=v*M+_*R+x*D+y*U,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],c=e[2],h=e[6],d=e[10],u=e[14];return e[3]*(+r*o*h-i*l*h-r*s*d+n*l*d+i*s*u-n*o*u)+e[7]*(+t*o*u-t*l*d+r*a*d-i*a*u+i*l*c-r*o*c)+e[11]*(+t*l*h-t*s*u-r*a*h+n*a*u+r*s*c-n*l*c)+e[15]*(-i*s*c-t*o*h+t*s*d+i*a*h-n*a*d+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=e[9],d=e[10],u=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=h*m*l-f*d*l+f*o*u-s*m*u-h*o*g+s*d*g,_=p*d*l-c*m*l-p*o*u+a*m*u+c*o*g-a*d*g,x=c*f*l-p*h*l+p*s*u-a*f*u-c*s*g+a*h*g,y=p*h*o-c*f*o-p*s*d+a*f*d+c*s*m-a*h*m,S=t*v+n*_+i*x+r*y;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/S;return e[0]=v*w,e[1]=(f*d*r-h*m*r-f*i*u+n*m*u+h*i*g-n*d*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(h*o*r-s*d*r-h*i*l+n*d*l+s*i*u-n*o*u)*w,e[4]=_*w,e[5]=(c*m*r-p*d*r+p*i*u-t*m*u-c*i*g+t*d*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*d*r-c*o*r+c*i*l-t*d*l-a*i*u+t*o*u)*w,e[8]=x*w,e[9]=(p*h*r-c*f*r-p*n*u+t*f*u+c*n*g-t*h*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(c*s*r-a*h*r-c*n*l+t*h*l+a*n*u-t*s*u)*w,e[12]=y*w,e[13]=(c*f*i-p*h*i+p*n*d-t*f*d-c*n*m+t*h*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*h*i-c*s*i+c*n*o-t*h*o-a*n*d+t*s*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,c=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,c*s+n,c*o-i*a,0,l*o-i*s,c*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,c=a+a,h=s+s,d=r*l,u=r*c,p=r*h,f=a*c,m=a*h,g=s*h,v=o*l,_=o*c,x=o*h,y=n.x,S=n.y,w=n.z;return i[0]=(1-(f+g))*y,i[1]=(u+x)*y,i[2]=(p-_)*y,i[3]=0,i[4]=(u-x)*S,i[5]=(1-(d+g))*S,i[6]=(m+v)*S,i[7]=0,i[8]=(p+_)*w,i[9]=(m-v)*w,i[10]=(1-(d+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Ct.set(i[0],i[1],i[2]).length();const a=Ct.set(i[4],i[5],i[6]).length(),s=Ct.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Pt.copy(this);const o=1/r,l=1/a,c=1/s;return Pt.elements[0]*=o,Pt.elements[1]*=o,Pt.elements[2]*=o,Pt.elements[4]*=l,Pt.elements[5]*=l,Pt.elements[6]*=l,Pt.elements[8]*=c,Pt.elements[9]*=c,Pt.elements[10]*=c,t.setFromRotationMatrix(Pt),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let u,p;if(s===le)u=-(a+r)/(a-r),p=-2*a*r/(a-r);else{if(s!==ce)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);u=-a/(a-r),p=-a*r/(a-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(a-r),d=(t+e)*l,u=(n+i)*c;let p,f;if(s===le)p=(a+r)*h,f=-2*h;else{if(s!==ce)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ct=new Qe,Pt=new Rt,Lt=new Qe(0,0,0),Dt=new Qe(1,1,1),It=new Qe,Nt=new Qe,Ot=new Qe,Ut=new Rt,Ft=new Je;class Bt{constructor(e=0,t=0,n=0,i=Bt.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],c=i[9],h=i[2],d=i[6],u=i[10];switch(t){case"XYZ":this._y=Math.asin(ge(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ge(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(ge(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ge(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ge(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(s,u));break;case"XZY":this._z=Math.asin(-ge(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ut.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ut,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ft.setFromEuler(this),this.setFromQuaternion(Ft,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}}Bt.DEFAULT_ORDER="XYZ";class zt{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){en.subVectors(i,t),tn.subVectors(n,t),nn.subVectors(e,t);const a=en.dot(en),s=en.dot(tn),o=en.dot(nn),l=tn.dot(tn),c=tn.dot(nn),h=a*l-s*s;if(0===h)return r.set(0,0,0),null;const d=1/h,u=(l*o-s*c)*d,p=(a*c-s*o)*d;return r.set(1-u-p,p,u)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,rn)&&rn.x>=0&&rn.y>=0&&rn.x+rn.y<=1}static getUV(e,t,n,i,r,a,s,o){return!1===dn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),dn=!0),this.getInterpolation(e,t,n,i,r,a,s,o)}static getInterpolation(e,t,n,i,r,a,s,o){return null===this.getBarycoord(e,t,n,i,rn)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,rn.x),o.addScaledVector(a,rn.y),o.addScaledVector(s,rn.z),o)}static isFrontFacing(e,t,n,i){return en.subVectors(n,t),tn.subVectors(e,t),en.cross(tn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return en.subVectors(this.c,this.b),tn.subVectors(this.a,this.b),.5*en.cross(tn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return un.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return un.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===dn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),dn=!0),un.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return un.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return un.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return un.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,s;an.subVectors(i,n),sn.subVectors(r,n),ln.subVectors(e,n);const o=an.dot(ln),l=sn.dot(ln);if(o<=0&&l<=0)return t.copy(n);cn.subVectors(e,i);const c=an.dot(cn),h=sn.dot(cn);if(c>=0&&h<=c)return t.copy(i);const d=o*h-c*l;if(d<=0&&o>=0&&c<=0)return a=o/(o-c),t.copy(n).addScaledVector(an,a);hn.subVectors(e,r);const u=an.dot(hn),p=sn.dot(hn);if(p>=0&&u<=p)return t.copy(r);const f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return s=l/(l-p),t.copy(n).addScaledVector(sn,s);const m=c*p-u*h;if(m<=0&&h-c>=0&&u-p>=0)return on.subVectors(r,i),s=(h-c)/(h-c+(u-p)),t.copy(i).addScaledVector(on,s);const g=1/(m+f+d);return a=f*g,s=d*g,t.copy(n).addScaledVector(an,a).addScaledVector(sn,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const pn={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},fn={h:0,s:0,l:0},mn={h:0,s:0,l:0};function gn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class vn{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){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,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=K){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Ue.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Ue.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ue.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Ue.workingColorSpace){if(e=ve(e,1),t=ge(t,0,1),n=ge(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=gn(r,i,e+1/3),this.g=gn(r,i,e),this.b=gn(r,i,e-1/3)}return Ue.toWorkingColorSpace(this,i),this}setStyle(e,t=K){function n(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 r;const a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[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=K){const n=pn[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Fe(e.r),this.g=Fe(e.g),this.b=Fe(e.b),this}copyLinearToSRGB(e){return this.r=Be(e.r),this.g=Be(e.g),this.b=Be(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=K){return Ue.fromWorkingColorSpace(_n.copy(this),e),65536*Math.round(ge(255*_n.r,0,255))+256*Math.round(ge(255*_n.g,0,255))+Math.round(ge(255*_n.b,0,255))}getHexString(e=K){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ue.workingColorSpace){Ue.fromWorkingColorSpace(_n.copy(this),t);const n=_n.r,i=_n.g,r=_n.b,a=Math.max(n,i,r),s=Math.min(n,i,r);let o,l;const c=(s+a)/2;if(s===a)o=0,l=0;else{const e=a-s;switch(l=c<=.5?e/(a+s):e/(2-a-s),a){case n:o=(i-r)/e+(i0!=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 n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n: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 n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==s&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==re&&(n.stencilFail=this.stencilFail),this.stencilZFail!==re&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==re&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class Sn extends yn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vn(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=o,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 wn=bn();function bn(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}const Mn={toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=ge(e,-65504,65504),wn.floatView[0]=e;const t=wn.uint32View[0],n=t>>23&511;return wn.baseTable[n]+((8388607&t)>>wn.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return wn.uint32View[0]=wn.mantissaTable[wn.offsetTable[t]+(1023&e)]+wn.exponentTable[t],wn.floatView[0]}},Tn=new Qe,En=new Me;class An{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=ae,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=D,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);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 n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}zn.copy(r).invert(),kn.copy(e.ray).applyMatrix4(zn),null!==n.boundingBox&&!1===kn.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,kn)}}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;rn.far?null:{distance:c,point:ti.clone(),object:e}}(e,t,n,i,Gn,Wn,jn,ei);if(h){r&&(qn.fromBufferAttribute(r,o),Zn.fromBufferAttribute(r,l),Kn.fromBufferAttribute(r,c),h.uv=un.getInterpolation(ei,Gn,Wn,jn,qn,Zn,Kn,new Me)),a&&(qn.fromBufferAttribute(a,o),Zn.fromBufferAttribute(a,l),Kn.fromBufferAttribute(a,c),h.uv1=un.getInterpolation(ei,Gn,Wn,jn,qn,Zn,Kn,new Me),h.uv2=h.uv1),s&&(Jn.fromBufferAttribute(s,o),Qn.fromBufferAttribute(s,l),$n.fromBufferAttribute(s,c),h.normal=un.getInterpolation(ei,Gn,Wn,jn,Jn,Qn,$n,new Qe),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c,normal:new Qe,materialIndex:0};un.getNormal(Gn,Wn,jn,e.normal),h.face=e}return h}class ri extends Bn{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const o=[],l=[],c=[],h=[];let d=0,u=0;function p(e,t,n,i,r,a,p,f,m,g,v){const _=a/m,x=p/g,y=a/2,S=p/2,w=f/2,b=m+1,M=g+1;let T=0,E=0;const A=new Qe;for(let a=0;a0?1:-1,c.push(A.x,A.y,A.z),h.push(o/m),h.push(1-a/g),T+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class hi extends $t{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=le}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class di extends hi{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=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*fe*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*pe*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*fe*Math.atan(Math.tan(.5*pe*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,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=n,this.view.offsetY=i,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*pe*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}const s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ui=-90;class pi extends $t{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new di(ui,1,e,t);i.layers=this.layers,this.add(i);const r=new di(ui,1,e,t);r.layers=this.layers,this.add(r);const a=new di(ui,1,e,t);a.layers=this.layers,this.add(a);const s=new di(ui,1,e,t);s.layers=this.layers,this.add(s);const o=new di(ui,1,e,t);o.layers=this.layers,this.add(o);const l=new di(ui,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(const e of t)this.remove(e);if(e===le)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.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),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==ce)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.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),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,s,o,l,c]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,c),e.setRenderTarget(h,d,u),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class fi extends je{constructor(e,t,n,i,r,a,s,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:_,n,i,r,a,s,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class mi extends qe{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(Le("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===q?K:Z),this.texture=new fi(i,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:A}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new ri(5,5,5),s=new ci({name:"CubemapFromEquirect",uniforms:ai(n),vertexShader:i,fragmentShader:r,side:1,blending:0});s.uniforms.tEquirect.value=t;const o=new ni(a,s),l=t.minFilter;return t.minFilter===R&&(t.minFilter=A),new pi(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const gi=new Qe,vi=new Qe,_i=new Te;class xi{constructor(e=new Qe(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=gi.subVectors(n,t).cross(vi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(gi),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||_i.getNormalMatrix(e),i=this.coplanarPoint(gi).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const yi=new xt,Si=new Qe;class wi{constructor(e=new xi,t=new xi,n=new xi,i=new xi,r=new xi,a=new xi){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],c=i[5],h=i[6],d=i[7],u=i[8],p=i[9],f=i[10],m=i[11],g=i[12],v=i[13],_=i[14],x=i[15];if(n[0].setComponents(o-r,d-l,m-u,x-g).normalize(),n[1].setComponents(o+r,d+l,m+u,x+g).normalize(),n[2].setComponents(o+a,d+c,m+p,x+v).normalize(),n[3].setComponents(o-a,d-c,m-p,x-v).normalize(),n[4].setComponents(o-s,d-h,m-f,x-_).normalize(),t===le)n[5].setComponents(o+s,d+h,m+f,x+_).normalize();else{if(t!==ce)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,h,f,_).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),yi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),yi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(yi)}intersectsSprite(e){return yi.center.set(0,0,0),yi.radius=.7071067811865476,yi.applyMatrix4(e.matrixWorld),this.intersectsSphere(yi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,Si.y=i.normal.y>0?e.max.y:e.min.y,Si.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Si)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function bi(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Mi(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\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_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\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 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\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\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\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}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor *= toneMappingExposure;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\treturn 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_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},Ai={common:{diffuse:{value:new vn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Te},alphaMap:{value:null},alphaMapTransform:{value:new Te},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Te}},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 Te}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Te}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Te},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Te},normalScale:{value:new Me(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Te},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Te}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Te}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Te}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vn(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 vn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Te},alphaTest:{value:0},uvTransform:{value:new Te}},sprite:{diffuse:{value:new vn(16777215)},opacity:{value:1},center:{value:new Me(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Te},alphaMap:{value:null},alphaMapTransform:{value:new Te},alphaTest:{value:0}}},Ri={basic:{uniforms:si([Ai.common,Ai.specularmap,Ai.envmap,Ai.aomap,Ai.lightmap,Ai.fog]),vertexShader:Ei.meshbasic_vert,fragmentShader:Ei.meshbasic_frag},lambert:{uniforms:si([Ai.common,Ai.specularmap,Ai.envmap,Ai.aomap,Ai.lightmap,Ai.emissivemap,Ai.bumpmap,Ai.normalmap,Ai.displacementmap,Ai.fog,Ai.lights,{emissive:{value:new vn(0)}}]),vertexShader:Ei.meshlambert_vert,fragmentShader:Ei.meshlambert_frag},phong:{uniforms:si([Ai.common,Ai.specularmap,Ai.envmap,Ai.aomap,Ai.lightmap,Ai.emissivemap,Ai.bumpmap,Ai.normalmap,Ai.displacementmap,Ai.fog,Ai.lights,{emissive:{value:new vn(0)},specular:{value:new vn(1118481)},shininess:{value:30}}]),vertexShader:Ei.meshphong_vert,fragmentShader:Ei.meshphong_frag},standard:{uniforms:si([Ai.common,Ai.envmap,Ai.aomap,Ai.lightmap,Ai.emissivemap,Ai.bumpmap,Ai.normalmap,Ai.displacementmap,Ai.roughnessmap,Ai.metalnessmap,Ai.fog,Ai.lights,{emissive:{value:new vn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ei.meshphysical_vert,fragmentShader:Ei.meshphysical_frag},toon:{uniforms:si([Ai.common,Ai.aomap,Ai.lightmap,Ai.emissivemap,Ai.bumpmap,Ai.normalmap,Ai.displacementmap,Ai.gradientmap,Ai.fog,Ai.lights,{emissive:{value:new vn(0)}}]),vertexShader:Ei.meshtoon_vert,fragmentShader:Ei.meshtoon_frag},matcap:{uniforms:si([Ai.common,Ai.bumpmap,Ai.normalmap,Ai.displacementmap,Ai.fog,{matcap:{value:null}}]),vertexShader:Ei.meshmatcap_vert,fragmentShader:Ei.meshmatcap_frag},points:{uniforms:si([Ai.points,Ai.fog]),vertexShader:Ei.points_vert,fragmentShader:Ei.points_frag},dashed:{uniforms:si([Ai.common,Ai.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ei.linedashed_vert,fragmentShader:Ei.linedashed_frag},depth:{uniforms:si([Ai.common,Ai.displacementmap]),vertexShader:Ei.depth_vert,fragmentShader:Ei.depth_frag},normal:{uniforms:si([Ai.common,Ai.bumpmap,Ai.normalmap,Ai.displacementmap,{opacity:{value:1}}]),vertexShader:Ei.meshnormal_vert,fragmentShader:Ei.meshnormal_frag},sprite:{uniforms:si([Ai.sprite,Ai.fog]),vertexShader:Ei.sprite_vert,fragmentShader:Ei.sprite_frag},background:{uniforms:{uvTransform:{value:new Te},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ei.background_vert,fragmentShader:Ei.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ei.backgroundCube_vert,fragmentShader:Ei.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ei.cube_vert,fragmentShader:Ei.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ei.equirect_vert,fragmentShader:Ei.equirect_frag},distanceRGBA:{uniforms:si([Ai.common,Ai.displacementmap,{referencePosition:{value:new Qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ei.distanceRGBA_vert,fragmentShader:Ei.distanceRGBA_frag},shadow:{uniforms:si([Ai.lights,Ai.fog,{color:{value:new vn(0)},opacity:{value:1}}]),vertexShader:Ei.shadow_vert,fragmentShader:Ei.shadow_frag}};Ri.physical={uniforms:si([Ri.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Te},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Te},clearcoatNormalScale:{value:new Me(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Te},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Te},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Te},sheen:{value:0},sheenColor:{value:new vn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Te},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Te},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Te},transmissionSamplerSize:{value:new Me},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Te},attenuationDistance:{value:0},attenuationColor:{value:new vn(0)},specularColor:{value:new vn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Te},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Te},anisotropyVector:{value:new Me},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Te}}]),vertexShader:Ei.meshphysical_vert,fragmentShader:Ei.meshphysical_frag};const Ci={r:0,b:0,g:0};function Pi(e,t,n,i,r,a,s){const o=new vn(0);let l,c,h=!0===a?0:1,d=null,u=0,p=null;function f(t,n){t.getRGB(Ci,oi(e)),i.buffers.color.setClear(Ci.r,Ci.g,Ci.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,f(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,f(o,h)},render:function(a,m){let g=!1,v=!0===m.isScene?m.background:null;v&&v.isTexture&&(v=(m.backgroundBlurriness>0?n:t).get(v)),null===v?f(o,h):v&&v.isColor&&(f(v,1),g=!0);const _=e.xr.getEnvironmentBlendMode();"additive"===_?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===_&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===y)?(void 0===c&&(c=new ni(new ri(1,1,1),new ci({name:"BackgroundCubeMaterial",uniforms:ai(Ri.backgroundCube.uniforms),vertexShader:Ri.backgroundCube.vertexShader,fragmentShader:Ri.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,c.material.toneMapped=Ue.getTransfer(v.colorSpace)!==te,d===v&&u===v.version&&p===e.toneMapping||(c.material.needsUpdate=!0,d=v,u=v.version,p=e.toneMapping),c.layers.enableAll(),a.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(void 0===l&&(l=new ni(new Ti(2,2),new ci({name:"BackgroundMaterial",uniforms:ai(Ri.background.uniforms),vertexShader:Ri.background.vertexShader,fragmentShader:Ri.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=Ue.getTransfer(v.colorSpace)!==te,!0===v.matrixAutoUpdate&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),d===v&&u===v.version&&p===e.toneMapping||(l.material.needsUpdate=!0,d=v,u=v.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null))}}}function Li(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),s=i.isWebGL2||null!==a,o={},l=p(null);let c=l,h=!1;function d(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function u(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e=0){const n=r[t];let i=a[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;s++}return c.attributesNum!==s||c.index!==i}(r,x,u,y),S&&function(e,t,n,i){const r={},a=t.attributes;let s=0;const o=n.getAttributes();for(const t in o)if(o[t].location>=0){let n=a[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,s++}c.attributes=r,c.attributesNum=s,c.index=i}(r,x,u,y)}else{const e=!0===l.wireframe;c.geometry===x.id&&c.program===u.id&&c.wireframe===e||(c.geometry=x.id,c.program=u.id,c.wireframe=e,S=!0)}null!==y&&n.update(y,e.ELEMENT_ARRAY_BUFFER),(S||h)&&(h=!1,function(r,a,s,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();const l=o.attributes,c=s.getAttributes(),h=a.defaultAttributeValues;for(const t in c){const a=c[t];if(a.location>=0){let s=l[t];if(void 0===s&&("instanceMatrix"===t&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){const t=s.normalized,l=s.itemSize,c=n.get(s);if(void 0===c)continue;const h=c.buffer,d=c.type,u=c.bytesPerElement,p=!0===i.isWebGL2&&(d===e.INT||d===e.UNSIGNED_INT||1013===s.gpuType);if(s.isInterleavedBufferAttribute){const n=s.data,i=n.stride,c=s.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&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 a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let s=void 0!==n.precision?n.precision:"highp";const o=r(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=a||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),_=d>0,x=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:u,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:x,floatVertexTextures:_&&x,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function Ni(e){const t=this;let n=null,i=0,r=!1,a=!1;const s=new xi,o=new Te,l={value:null,needsUpdate:!1};function c(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),t.numPlanes=i,t.numIntersection=0);else{const e=a?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(d,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=e}}}function Oi(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=_:304===t&&(e.mapping=x),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping;if(303===a||304===a){if(t.has(r))return n(t.get(r).texture,r.mapping);{const a=r.image;if(a&&a.height>0){const s=new mi(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class Ui extends hi{constructor(e=-1,t=1,n=1,i=-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=n,this.bottom=i,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,n,i,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=n,this.view.offsetY=i,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,s=i+t,o=i-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,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,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 Fi=[.125,.215,.35,.446,.526,.582],Bi=new Ui,zi=new vn;let ki=null,Hi=0,Vi=0;const Gi=(1+Math.sqrt(5))/2,Wi=1/Gi,ji=[new Qe(1,1,1),new Qe(-1,1,1),new Qe(1,1,-1),new Qe(-1,1,-1),new Qe(0,Gi,Wi),new Qe(0,Gi,-Wi),new Qe(Wi,0,Gi),new Qe(-Wi,0,Gi),new Qe(Gi,Wi,0),new Qe(-Gi,Wi,0)];class Xi{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){ki=this._renderer.getRenderTarget(),Hi=this._renderer.getActiveCubeFace(),Vi=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ki(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Zi(),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;ee-4?o=Fi[s-e+4-1]:0===s&&(o=0),i.push(o);const l=1/(a-2),c=-l,h=1+l,d=[c,c,h,c,h,h,c,c,h,h,c,h],u=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*u),_=new Float32Array(m*p*u),x=new Float32Array(g*p*u);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),_.set(d,m*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const y=new Bn;y.setAttribute("position",new An(v,f)),y.setAttribute("uv",new An(_,m)),y.setAttribute("faceIndex",new An(x,g)),t.push(y),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(20),r=new Qe(0,1,0);return new ci({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\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",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(i,e,t)}return i}_compileMaterial(e){const t=new ni(this._lodPlanes[0],e);this._renderer.compile(t,Bi)}_sceneToCubeUV(e,t,n,i){const r=new di(90,1,t,n),a=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(zi),o.toneMapping=h,o.autoClear=!1;const d=new Sn({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new ni(new ri,d);let p=!1;const f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,p=!0):(d.color.copy(zi),p=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,a[t],0),r.lookAt(s[t],0,0)):1===n?(r.up.set(0,0,a[t]),r.lookAt(0,s[t],0)):(r.up.set(0,a[t],0),r.lookAt(0,0,s[t]));const l=this._cubeSize;qi(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),p&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===_||e.mapping===x;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ki()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Zi());const r=i?this._cubemapMaterial:this._equirectMaterial,a=new ni(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const s=this._cubeSize;qi(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Bi)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:ev-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(c,Bi)}}function Yi(e,t,n){const i=new qe(e,t,n);return i.texture.mapping=y,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function qi(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Zi(){return new ci({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\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",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Ki(){return new ci({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\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",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 Ji(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===_||a===x;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Xi(e)),i=s?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const a=r.image;if(s&&a&&a.height>0||o&&a&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(a)){null===n&&(n=new Xi(e));const a=s?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",i),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Qi(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=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":i=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":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?(n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance")):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function $i(e,t,n,i){const r={},a=new WeakMap;function s(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 n=o.morphAttributes[e];for(let e=0,i=n.length;et.maxTextureSize&&(T=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const E=new Float32Array(M*T*4*p),A=new Ze(E,M,T,p);A.type=D,A.needsUpdate=!0;const R=4*b;for(let P=0;P0)return e;const r=t*n;let a=ur[r];if(void 0===a&&(a=new Float32Array(r),ur[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function _r(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function ga(e,t){const n=function(e){const t=Ue.getPrimaries(Ue.workingColorSpace),n=Ue.getPrimaries(e);let i;switch(t===n?i="":t===ie&&n===ne?i="LinearDisplayP3ToLinearSRGB":t===ne&&n===ie&&(i="LinearSRGBToLinearDisplayP3"),e){case J:case $:return[i,"LinearTransferOETF"];case K:case Q:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),[i,"LinearTransferOETF"]}}(t);return`vec4 ${e}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function va(e,t){let n;switch(t){case d:n="Linear";break;case u:n="Reinhard";break;case p:n="OptimizedCineon";break;case f:n="ACESFilmic";break;case g:n="AgX";break;case m:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function _a(e){return""!==e}function xa(e,t){const n=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,n).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 ya(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Sa=/^[ \t]*#include +<([\w\d./]+)>/gm;function wa(e){return e.replace(Sa,Ma)}const ba=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Ma(e,t){let n=Ei[t];if(void 0===n){const e=ba.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Ei[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return wa(n)}const Ta=/#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 Ea(e){return e.replace(Ta,Aa)}function Aa(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(A+="\n"),R=[b,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,T].filter(_a).join("\n"),R.length>0&&(R+="\n")):(A=[Ra(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,T,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+v:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.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(_a).join("\n"),R=[b,Ra(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,T,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+g:"",n.envMap?"#define "+v:"",n.envMap?"#define "+S:"",w?"#define CUBEUV_TEXEL_WIDTH "+w.texelWidth:"",w?"#define CUBEUV_TEXEL_HEIGHT "+w.texelHeight:"",w?"#define CUBEUV_MAX_MIP "+w.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+m:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==h?"#define TONE_MAPPING":"",n.toneMapping!==h?Ei.tonemapping_pars_fragment:"",n.toneMapping!==h?va("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ei.colorspace_pars_fragment,ga("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(_a).join("\n")),p=wa(p),p=xa(p,n),p=ya(p,n),f=wa(f),f=xa(f,n),f=ya(f,n),p=Ea(p),f=Ea(f),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(C="#version 300 es\n",A=[M,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+A,R=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===se?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===se?"":"#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"+R);const P=C+A+p,L=C+R+f,D=ua(d,d.VERTEX_SHADER,P),I=ua(d,d.FRAGMENT_SHADER,L);function N(t){if(e.debug.checkShaderErrors){const n=d.getProgramInfoLog(E).trim(),i=d.getShaderInfoLog(D).trim(),r=d.getShaderInfoLog(I).trim();let a=!0,s=!0;if(!1===d.getProgramParameter(E,d.LINK_STATUS))if(a=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(d,E,D,I);else{const e=ma(d,D,"vertex"),t=ma(d,I,"fragment");console.error("THREE.WebGLProgram: Shader Error "+d.getError()+" - VALIDATE_STATUS "+d.getProgramParameter(E,d.VALIDATE_STATUS)+"\n\nProgram Info Log: "+n+"\n"+e+"\n"+t)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==r||(s=!1);s&&(t.diagnostics={runnable:a,programLog:n,vertexShader:{log:i,prefix:A},fragmentShader:{log:r,prefix:R}})}d.deleteShader(D),d.deleteShader(I),O=new da(d,E),U=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,q=a.clearcoat>0,Z=a.iridescence>0,K=a.sheen>0,Q=a.transmission>0,$=Y&&!!a.anisotropyMap,ee=q&&!!a.clearcoatMap,ne=q&&!!a.clearcoatNormalMap,ie=q&&!!a.clearcoatRoughnessMap,re=Z&&!!a.iridescenceMap,ae=Z&&!!a.iridescenceThicknessMap,se=K&&!!a.sheenColorMap,oe=K&&!!a.sheenRoughnessMap,le=!!a.specularMap,ce=!!a.specularColorMap,he=!!a.specularIntensityMap,de=Q&&!!a.transmissionMap,ue=Q&&!!a.thicknessMap,pe=!!a.gradientMap,fe=!!a.alphaMap,me=a.alphaTest>0,ge=!!a.alphaHash,ve=!!a.extensions,_e=!!S.attributes.uv1,xe=!!S.attributes.uv2,ye=!!S.attributes.uv3;let Se=h;return a.toneMapped&&(null!==I&&!0!==I.isXRRenderTarget||(Se=e.toneMapping)),{isWebGL2:d,shaderID:T,shaderType:a.type,shaderName:a.name,vertexShader:R,fragmentShader:C,defines:a.defines,customVertexShaderID:P,customFragmentShaderID:L,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,batching:O,instancing:N,instancingColor:N&&null!==_.instanceColor,supportsVertexTextures:p,outputColorSpace:null===I?e.outputColorSpace:!0===I.isXRRenderTarget?I.texture.colorSpace:J,map:U,matcap:F,envMap:B,envMapMode:B&&b.mapping,envMapCubeUVHeight:M,aoMap:z,lightMap:k,bumpMap:H,normalMap:V,displacementMap:p&&G,emissiveMap:W,normalMapObjectSpace:V&&1===a.normalMapType,normalMapTangentSpace:V&&0===a.normalMapType,metalnessMap:j,roughnessMap:X,anisotropy:Y,anisotropyMap:$,clearcoat:q,clearcoatMap:ee,clearcoatNormalMap:ne,clearcoatRoughnessMap:ie,iridescence:Z,iridescenceMap:re,iridescenceThicknessMap:ae,sheen:K,sheenColorMap:se,sheenRoughnessMap:oe,specularMap:le,specularColorMap:ce,specularIntensityMap:he,transmission:Q,transmissionMap:de,thicknessMap:ue,gradientMap:pe,opaque:!1===a.transparent&&1===a.blending,alphaMap:fe,alphaTest:me,alphaHash:ge,combine:a.combine,mapUv:U&&g(a.map.channel),aoMapUv:z&&g(a.aoMap.channel),lightMapUv:k&&g(a.lightMap.channel),bumpMapUv:H&&g(a.bumpMap.channel),normalMapUv:V&&g(a.normalMap.channel),displacementMapUv:G&&g(a.displacementMap.channel),emissiveMapUv:W&&g(a.emissiveMap.channel),metalnessMapUv:j&&g(a.metalnessMap.channel),roughnessMapUv:X&&g(a.roughnessMap.channel),anisotropyMapUv:$&&g(a.anisotropyMap.channel),clearcoatMapUv:ee&&g(a.clearcoatMap.channel),clearcoatNormalMapUv:ne&&g(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&g(a.clearcoatRoughnessMap.channel),iridescenceMapUv:re&&g(a.iridescenceMap.channel),iridescenceThicknessMapUv:ae&&g(a.iridescenceThicknessMap.channel),sheenColorMapUv:se&&g(a.sheenColorMap.channel),sheenRoughnessMapUv:oe&&g(a.sheenRoughnessMap.channel),specularMapUv:le&&g(a.specularMap.channel),specularColorMapUv:ce&&g(a.specularColorMap.channel),specularIntensityMapUv:he&&g(a.specularIntensityMap.channel),transmissionMapUv:de&&g(a.transmissionMap.channel),thicknessMapUv:ue&&g(a.thicknessMap.channel),alphaMapUv:fe&&g(a.alphaMap.channel),vertexTangents:!!S.attributes.tangent&&(V||Y),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!S.attributes.color&&4===S.attributes.color.itemSize,vertexUv1s:_e,vertexUv2s:xe,vertexUv3s:ye,pointsUvs:!0===_.isPoints&&!!S.attributes.uv&&(U||fe),fog:!!x,useFog:!0===a.fog,fogExp2:x&&x.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==S.morphAttributes.position,morphNormals:void 0!==S.morphAttributes.normal,morphColors:void 0!==S.morphAttributes.color,morphTargetsCount:A,morphTextureStride:D,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:Se,useLegacyLights:e._useLegacyLights,decodeVideoTexture:U&&!0===a.map.isVideoTexture&&Ue.getTransfer(a.map.colorSpace)===te,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:ve&&!0===a.extensions.derivatives,extensionFragDepth:ve&&!0===a.extensions.fragDepth,extensionDrawBuffers:ve&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:ve&&!0===a.extensions.shaderTextureLOD,extensionClipCullDistance:ve&&a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:d||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(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.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0),t.supportsVertexTextures&&o.enable(1),t.instancing&&o.enable(2),t.instancingColor&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),t.alphaHash&&o.enable(18),t.batching&&o.enable(19),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.skinning&&o.enable(4),t.morphTargets&&o.enable(5),t.morphNormals&&o.enable(6),t.morphColors&&o.enable(7),t.premultipliedAlpha&&o.enable(8),t.shadowMapEnabled&&o.enable(9),t.useLegacyLights&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=m[e.type];let n;if(t){const e=Ri[t];n=li.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e0?i.push(h):!0===s.transparent?r.push(h):n.push(h)},unshift:function(e,t,s,o,l,c){const h=a(e,t,s,o,l,c);s.transmission>0?i.unshift(h):!0===s.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||Oa),i.length>1&&i.sort(t||Ua),r.length>1&&r.sort(t||Ua)}}}function Ba(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new Fa,e.set(t,[r])):n>=i.length?(r=new Fa,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function za(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Qe,color:new vn};break;case"SpotLight":n={position:new Qe,direction:new Qe,color:new vn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Qe,color:new vn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Qe,skyColor:new vn,groundColor:new vn};break;case"RectAreaLight":n={color:new vn,position:new Qe,halfWidth:new Qe,halfHeight:new Qe}}return e[t.id]=n,n}}}let ka=0;function Ha(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Va(e,t){const n=new za,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new Qe);const a=new Qe,s=new Rt,o=new Rt;return{setup:function(a,s){let o=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let h=0,d=0,u=0,p=0,f=0,m=0,g=0,v=0,_=0,x=0,y=0;a.sort(Ha);const S=!0===s?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2?!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Ai.LTC_FLOAT_1,r.rectAreaLTC2=Ai.LTC_FLOAT_2):(r.rectAreaLTC1=Ai.LTC_HALF_1,r.rectAreaLTC2=Ai.LTC_HALF_2):!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Ai.LTC_FLOAT_1,r.rectAreaLTC2=Ai.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Ai.LTC_HALF_1,r.rectAreaLTC2=Ai.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const w=r.hash;w.directionalLength===h&&w.pointLength===d&&w.spotLength===u&&w.rectAreaLength===p&&w.hemiLength===f&&w.numDirectionalShadows===m&&w.numPointShadows===g&&w.numSpotShadows===v&&w.numSpotMaps===_&&w.numLightProbes===y||(r.directional.length=h,r.spot.length=u,r.rectArea.length=p,r.point.length=d,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+_-x,r.spotLightMap.length=_,r.numSpotLightShadowsWithMaps=x,r.numLightProbes=y,w.directionalLength=h,w.pointLength=d,w.spotLength=u,w.rectAreaLength=p,w.hemiLength=f,w.numDirectionalShadows=m,w.numPointShadows=g,w.numSpotShadows=v,w.numSpotMaps=_,w.numLightProbes=y,r.version=ka++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const d=t.matrixWorldInverse;for(let t=0,u=e.length;t=a.length?(s=new Ga(e,t),a.push(s)):s=a[r],s},dispose:function(){n=new WeakMap}}}class ja extends yn{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 Xa extends yn{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 Ya(e,t,n){let r=new wi;const s=new Me,o=new Me,l=new Xe,c=new ja({depthPacking:3201}),h=new Xa,d={},u=n.maxTextureSize,p={0:1,1:0,2:2},f=new ci({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Me},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const g=new Bn;g.setAttribute("position",new An(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new ni(g,f),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=i;let x=this.type;function y(n,i){const r=t.update(v);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,m.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,m.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new qe(s.x,s.y)),f.uniforms.shadow_pass.value=n.map.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,f,v,null),m.uniforms.shadow_pass.value=n.mapPass.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,m,v,null)}function S(t,n,i,r){let s=null;const o=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)s=o;else if(s=!0===i.isPointLight?h:c,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let i=d[e];void 0===i&&(i={},d[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r,n.addEventListener("dispose",b)),s=r}return s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===a?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:p[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial&&(e.properties.get(s).light=i),s}function w(n,i,s,o,l){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&l===a)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const r=t.update(n),a=n.material;if(Array.isArray(a)){const t=r.groups;for(let c=0,h=t.length;cu||s.y>u)&&(s.x>u&&(o.x=Math.floor(u/g.x),s.x=o.x*g.x,d.mapSize.x=o.x),s.y>u&&(o.y=Math.floor(u/g.y),s.y=o.y*g.y,d.mapSize.y=o.y)),null===d.map||!0===f||!0===m){const e=this.type!==a?{minFilter:M,magFilter:M}:{};null!==d.map&&d.map.dispose(),d.map=new qe(s.x,s.y,e),d.map.texture.name=h.name+".shadowMap",d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();const v=d.getViewportCount();for(let e=0;e=1):-1!==N.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(N)[1]),D=I>=2);let O=null,U={};const F=e.getParameter(e.SCISSOR_BOX),B=e.getParameter(e.VIEWPORT),z=(new Xe).fromArray(F),k=(new Xe).fromArray(B);function H(t,n,r,a){const s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;oi||e.height>i)&&(r=i/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 i=t?ye:Math.floor,a=i(r*e.width),s=i(r*e.height);void 0===d&&(d=f(a,s));const o=n?f(a,s):d;return o.width=a,o.height=s,o.getContext("2d").drawImage(e,0,0,a,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+s+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function g(e){return xe(e.width)&&xe(e.height)}function v(e,t){return e.generateMipmaps&&t&&e.minFilter!==M&&e.minFilter!==A}function _(t){e.generateMipmap(t)}function x(n,i,r,a,s=!1){if(!1===o)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;if(i===e.RED&&(r===e.FLOAT&&(l=e.R32F),r===e.HALF_FLOAT&&(l=e.R16F),r===e.UNSIGNED_BYTE&&(l=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(l=e.R8UI),r===e.UNSIGNED_SHORT&&(l=e.R16UI),r===e.UNSIGNED_INT&&(l=e.R32UI),r===e.BYTE&&(l=e.R8I),r===e.SHORT&&(l=e.R16I),r===e.INT&&(l=e.R32I)),i===e.RG&&(r===e.FLOAT&&(l=e.RG32F),r===e.HALF_FLOAT&&(l=e.RG16F),r===e.UNSIGNED_BYTE&&(l=e.RG8)),i===e.RGBA){const t=s?ee:Ue.getTransfer(a);r===e.FLOAT&&(l=e.RGBA32F),r===e.HALF_FLOAT&&(l=e.RGBA16F),r===e.UNSIGNED_BYTE&&(l=t===te?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function y(e,t,n){return!0===v(e,n)||e.isFramebufferTexture&&e.minFilter!==M&&e.minFilter!==A?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 B(t){return t===M||t===T||t===E?e.NEAREST:e.LINEAR}function z(e){const t=e.target;t.removeEventListener("dispose",z),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=u.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&H(e),0===Object.keys(r).length&&u.delete(n)}i.remove(e)}(t),t.isVideoTexture&&h.delete(t)}function k(t){const n=t.target;n.removeEventListener("dispose",k),function(t){const n=t.texture,r=i.get(t),a=i.get(n);if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(r.__webglFramebuffer[t]))for(let n=0;n0&&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 K(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}const W={[S]:e.REPEAT,[w]:e.CLAMP_TO_EDGE,[b]:e.MIRRORED_REPEAT},j={[M]:e.NEAREST,[T]:e.NEAREST_MIPMAP_NEAREST,[E]:e.NEAREST_MIPMAP_LINEAR,[A]:e.LINEAR,1007:e.LINEAR_MIPMAP_NEAREST,[R]:e.LINEAR_MIPMAP_LINEAR},X={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function Y(n,a,s){if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,W[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,W[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,W[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,j[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,j[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),a.wrapS===w&&a.wrapT===w||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,B(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,B(a.minFilter)),a.minFilter!==M&&a.minFilter!==A&&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(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,X[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===M)return;if(a.minFilter!==E&&a.minFilter!==R)return;if(a.type===D&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&a.type===I&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function q(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",z));const r=n.source;let a=u.get(r);void 0===a&&(a={},u.set(r,a));const o=function(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()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&H(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function K(t,s,l){let c=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(c=e.TEXTURE_3D);const h=q(t,s),d=s.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+l);const u=i.get(d);if(d.version!==u.__version||!0===h){n.activeTexture(e.TEXTURE0+l);const t=Ue.getPrimaries(Ue.workingColorSpace),i=s.colorSpace===Z?null:Ue.getPrimaries(s.colorSpace),p=s.colorSpace===Z||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);const f=function(e){return!o&&(e.wrapS!==w||e.wrapT!==w||e.minFilter!==M&&e.minFilter!==A)}(s)&&!1===g(s.image);let S=m(s.image,f,!1,r.maxTextureSize);S=ae(s,S);const b=g(S)||o,T=a.convert(s.format,s.colorSpace);let E,R=a.convert(s.type),C=x(s.internalFormat,T,R,s.colorSpace,s.isVideoTexture);Y(c,s,b);const I=s.mipmaps,B=o&&!0!==s.isVideoTexture&&36196!==C,z=void 0===u.__version||!0===h,k=y(s,S,b);if(s.isDepthTexture)C=e.DEPTH_COMPONENT,o?C=s.type===D?e.DEPTH_COMPONENT32F:s.type===L?e.DEPTH_COMPONENT24:s.type===N?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:s.type===D&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),s.format===U&&C===e.DEPTH_COMPONENT&&s.type!==P&&s.type!==L&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),s.type=L,R=a.convert(s.type)),s.format===F&&C===e.DEPTH_COMPONENT&&(C=e.DEPTH_STENCIL,s.type!==N&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),s.type=N,R=a.convert(s.type))),z&&(B?n.texStorage2D(e.TEXTURE_2D,1,C,S.width,S.height):n.texImage2D(e.TEXTURE_2D,0,C,S.width,S.height,0,T,R,null));else if(s.isDataTexture)if(I.length>0&&b){B&&z&&n.texStorage2D(e.TEXTURE_2D,k,C,I[0].width,I[0].height);for(let t=0,i=I.length;t>=1,i>>=1}}else if(I.length>0&&b){B&&z&&n.texStorage2D(e.TEXTURE_2D,k,C,I[0].width,I[0].height);for(let t=0,i=I.length;t>h),i=Math.max(1,r.height>>h);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,t,i,r.depth,0,d,u,null):n.texImage2D(c,h,p,t,i,0,d,u,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),re(r)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,c,i.get(s).__webglTexture,0,ie(r)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,c,i.get(s).__webglTexture,h),n.bindFramebuffer(e.FRAMEBUFFER,null)}function $(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=!0===o?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(i||re(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===D?r=e.DEPTH_COMPONENT32F:t.type===L&&(r=e.DEPTH_COMPONENT24));const i=ie(n);re(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=ie(n);i&&!1===re(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):re(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function ae(e,n){const i=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===oe||i!==J&&i!==Z&&(Ue.getTransfer(i)===te?!1===o?!0===t.has("EXT_sRGB")&&r===O?(e.format=oe,e.minFilter=A,e.generateMipmaps=!1):n=ke.sRGBToLinear(n):r===O&&a===C||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const e=V;return e>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),V+=1,e},this.resetTextureUnits=function(){V=0},this.setTexture2D=G,this.setTexture2DArray=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?K(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?K(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){const l=i.get(t);t.version>0&&l.__version!==t.version?function(t,s,l){if(6!==s.image.length)return;const c=q(t,s),h=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+l);const d=i.get(h);if(h.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+l);const t=Ue.getPrimaries(Ue.workingColorSpace),i=s.colorSpace===Z?null:Ue.getPrimaries(s.colorSpace),u=s.colorSpace===Z||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);const p=s.isCompressedTexture||s.image[0].isCompressedTexture,f=s.image[0]&&s.image[0].isDataTexture,S=[];for(let e=0;e<6;e++)S[e]=p||f?f?s.image[e].image:s.image[e]:m(s.image[e],!1,!0,r.maxCubemapSize),S[e]=ae(s,S[e]);const w=S[0],b=g(w)||o,M=a.convert(s.format,s.colorSpace),T=a.convert(s.type),E=x(s.internalFormat,M,T,s.colorSpace),A=o&&!0!==s.isVideoTexture,R=void 0===d.__version||!0===c;let C,P=y(s,w,b);if(Y(e.TEXTURE_CUBE_MAP,s,b),p){A&&R&&n.texStorage2D(e.TEXTURE_CUBE_MAP,P,E,w.width,w.height);for(let t=0;t<6;t++){C=S[t].mipmaps;for(let i=0;i0&&P++,n.texStorage2D(e.TEXTURE_CUBE_MAP,P,E,S[0].width,S[0].height));for(let t=0;t<6;t++)if(f){A?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,S[t].width,S[t].height,M,T,S[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,S[t].width,S[t].height,0,M,T,S[t].data);for(let i=0;i0){c.__webglFramebuffer[t]=[];for(let n=0;n0){c.__webglFramebuffer=[];for(let t=0;t0&&!1===re(t)){const i=u?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0&&!1===re(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;const l=[],h=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,d=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent($a)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Qa;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class ts extends he{constructor(e,t){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,c=null,h=null,d=null,u=null,p=null;const f=t.getContextAttributes();let m=null,g=null;const v=[],_=[],x=new Me;let y=null;const S=new di;S.layers.enable(1),S.viewport=new Xe;const w=new di;w.layers.enable(2),w.viewport=new Xe;const b=[S,w],M=new Ja;M.layers.enable(1),M.layers.enable(2);let T=null,E=null;function A(e){const t=_.indexOf(e.inputSource);if(-1===t)return;const n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){i.removeEventListener("select",A),i.removeEventListener("selectstart",A),i.removeEventListener("selectend",A),i.removeEventListener("squeeze",A),i.removeEventListener("squeezestart",A),i.removeEventListener("squeezeend",A),i.removeEventListener("end",R),i.removeEventListener("inputsourceschange",P);for(let e=0;e=0&&(_[i]=null,v[i].disconnect(n))}for(let t=0;t=_.length){_.push(n),i=e;break}if(null===_[e]){_[e]=n,i=e;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new es,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new es,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new es,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",A),i.addEventListener("selectstart",A),i.addEventListener("selectend",A),i.addEventListener("squeeze",A),i.addEventListener("squeezestart",A),i.addEventListener("squeezeend",A),i.addEventListener("end",R),i.addEventListener("inputsourceschange",P),!0!==f.xrCompatible&&await t.makeXRCompatible(),y=e.getPixelRatio(),e.getSize(x),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),g=new qe(u.framebufferWidth,u.framebufferHeight,{format:O,type:C,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,a=null,s=null;f.depth&&(s=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?F:U,a=f.stencil?N:L);const o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(o),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),g=new qe(d.textureWidth,d.textureHeight,{format:O,type:C,depthTexture:new sr(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),k.setContext(i),k.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const D=new Qe,I=new Qe;function B(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===i)return;M.near=w.near=S.near=e.near,M.far=w.far=S.far=e.far,T===M.near&&E===M.far||(i.updateRenderState({depthNear:M.near,depthFar:M.far}),T=M.near,E=M.far);const t=e.parent,n=M.cameras;B(M,t);for(let e=0;e0&&(i.alphaTest.value=r.alphaTest);const a=t.get(r).envMap;if(a&&(i.envMap.value=a,i.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const t=!0===e._useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,oi(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform)),e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform));t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(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,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(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,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(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,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(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,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(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,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function is(e,t,n,i){let r={},a={},s=[];const o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n,i){const r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==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 h(t){const n=t.target;n.removeEventListener("dispose",h);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let u=r[n.id];void 0===u&&(function(e){const t=e.uniforms;let n=0;for(let e=0,i=t.length;e0&&(n+=16-i),e.__size=n,e.__cache={}}(n),u=function(t){const n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,f=!!n.morphAttributes.color;let m=h;i.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(m=y.toneMapping));const g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=void 0!==g?g.length:0,x=ce.get(i),S=v.state.lights;if(!0===Z&&(!0===Q||e!==E)){const t=e===E&&i.id===T;Se.setState(i,e,t)}let w=!1;i.version===x.__version?x.needsLights&&x.lightsStateVersion!==S.state.version||x.outputColorSpace!==o||r.isBatchedMesh&&!1===x.batching?w=!0:r.isBatchedMesh||!0!==x.batching?r.isInstancedMesh&&!1===x.instancing?w=!0:r.isInstancedMesh||!0!==x.instancing?r.isSkinnedMesh&&!1===x.skinning?w=!0:r.isSkinnedMesh||!0!==x.skinning?r.isInstancedMesh&&!0===x.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===x.instancingColor&&null!==r.instanceColor||x.envMap!==l||!0===i.fog&&x.fog!==a?w=!0:void 0===x.numClippingPlanes||x.numClippingPlanes===Se.numPlanes&&x.numIntersection===Se.numIntersection?(x.vertexAlphas!==c||x.vertexTangents!==d||x.morphTargets!==u||x.morphNormals!==p||x.morphColors!==f||x.toneMapping!==m||!0===se.isWebGL2&&x.morphTargetsCount!==_)&&(w=!0):w=!0:w=!0:w=!0:w=!0:(w=!0,x.__version=i.version);let b=x.currentProgram;!0===w&&(b=Je(i,t,r));let A=!1,R=!1,C=!1;const P=b.getUniforms(),L=x.uniforms;if(oe.useProgram(b.program)&&(A=!0,R=!0,C=!0),i.id!==T&&(T=i.id,R=!0),A||E!==e){P.setValue(De,"projectionMatrix",e.projectionMatrix),P.setValue(De,"viewMatrix",e.matrixWorldInverse);const t=P.map.cameraPosition;void 0!==t&&t.setValue(De,ne.setFromMatrixPosition(e.matrixWorld)),se.logarithmicDepthBuffer&&P.setValue(De,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(De,"isOrthographic",!0===e.isOrthographicCamera),E!==e&&(E=e,R=!0,C=!0)}if(r.isSkinnedMesh){P.setOptional(De,r,"bindMatrix"),P.setOptional(De,r,"bindMatrixInverse");const e=r.skeleton;e&&(se.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(De,"boneTexture",e.boneTexture,he)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}r.isBatchedMesh&&(P.setOptional(De,r,"batchingTexture"),P.setValue(De,"batchingTexture",r._matricesTexture,he));const D=n.morphAttributes;var I,N;if((void 0!==D.position||void 0!==D.normal||void 0!==D.color&&!0===se.isWebGL2)&&Te.update(r,n,b),(R||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(De,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(L.envMap.value=l,L.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),R&&(P.setValue(De,"toneMappingExposure",y.toneMappingExposure),x.needsLights&&(N=C,(I=L).ambientLightColor.needsUpdate=N,I.lightProbe.needsUpdate=N,I.directionalLights.needsUpdate=N,I.directionalLightShadows.needsUpdate=N,I.pointLights.needsUpdate=N,I.pointLightShadows.needsUpdate=N,I.spotLights.needsUpdate=N,I.spotLightShadows.needsUpdate=N,I.rectAreaLights.needsUpdate=N,I.hemisphereLights.needsUpdate=N),a&&!0===i.fog&&ve.refreshFogUniforms(L,a),ve.refreshMaterialUniforms(L,i,V,H,$),da.upload(De,$e(x),L,he)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(da.upload(De,$e(x),L,he),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&P.setValue(De,"center",r.center),P.setValue(De,"modelViewMatrix",r.modelViewMatrix),P.setValue(De,"normalMatrix",r.normalMatrix),P.setValue(De,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t{function n(){i.forEach((function(e){ce.get(e).currentProgram.isReady()&&i.delete(e)})),0!==i.size?setTimeout(n,10):t(e)}null!==ae.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let He=null;function Ve(){We.stop()}function Ge(){We.start()}const We=new bi;function je(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=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||q.intersectsSprite(e)){i&&ne.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ee);const t=me.update(e),r=e.material;r.visible&&g.push(e,t,r,n,ne.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||q.intersectsObject(e))){const t=me.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),ne.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),ne.copy(t.boundingSphere.center)),ne.applyMatrix4(e.matrixWorld).applyMatrix4(ee)),Array.isArray(r)){const i=t.groups;for(let a=0,s=i.length;a0&&function(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;const r=se.isWebGL2;null===$&&($=new qe(1,1,{generateMipmaps:!0,type:ae.has("EXT_color_buffer_half_float")?I:C,minFilter:R,samples:r?4:0})),y.getDrawingBufferSize(te),r?$.setSize(te.x,te.y):$.setSize(ye(te.x),ye(te.y));const a=y.getRenderTarget();y.setRenderTarget($),y.getClearColor(B),z=y.getClearAlpha(),z<1&&y.setClearColor(16777215,.5),y.clear();const s=y.toneMapping;y.toneMapping=h,Ze(e,n,i),he.updateMultisampleRenderTarget($),he.updateRenderTargetMipmap($);let o=!1;for(let e=0,r=t.length;e0&&Ze(r,t,n),a.length>0&&Ze(a,t,n),s.length>0&&Ze(s,t,n),oe.buffers.depth.setTest(!0),oe.buffers.depth.setMask(!0),oe.buffers.color.setMask(!0),oe.setPolygonOffset(!1)}function Ze(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r0?x[x.length-1]:null,_.pop(),g=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(e,t,n){ce.get(e.texture).__webglTexture=t,ce.get(e.depthTexture).__webglTexture=n;const i=ce.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===ae.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=ce.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){M=e,w=t,b=n;let i=!0,r=null,a=!1,s=!1;if(e){const o=ce.get(e);void 0!==o.__useDefaultFramebuffer?(oe.bindFramebuffer(De.FRAMEBUFFER,null),i=!1):void 0===o.__webglFramebuffer?he.setupRenderTarget(e):o.__hasExternalTextures&&he.rebindTextures(e,ce.get(e.texture).__webglTexture,ce.get(e.depthTexture).__webglTexture);const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=ce.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=se.isWebGL2&&e.samples>0&&!1===he.useMultisampledRTT(e)?ce.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,A.copy(e.viewport),U.copy(e.scissor),F=e.scissorTest}else A.copy(j).multiplyScalar(V).floor(),U.copy(X).multiplyScalar(V).floor(),F=Y;if(oe.bindFramebuffer(De.FRAMEBUFFER,r)&&se.drawBuffers&&i&&oe.drawBuffers(e,r),oe.viewport(A),oe.scissor(U),oe.setScissorTest(F),a){const i=ce.get(e.texture);De.framebufferTexture2D(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,De.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=ce.get(e.texture),r=t||0;De.framebufferTextureLayer(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}T=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=ce.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){oe.bindFramebuffer(De.FRAMEBUFFER,o);try{const s=e.texture,o=s.format,l=s.type;if(o!==O&&Re.convert(o)!==De.getParameter(De.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===I&&(ae.has("EXT_color_buffer_half_float")||se.isWebGL2&&ae.has("EXT_color_buffer_float"));if(!(l===C||Re.convert(l)===De.getParameter(De.IMPLEMENTATION_COLOR_READ_TYPE)||l===D&&(se.isWebGL2||ae.has("OES_texture_float")||ae.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&De.readPixels(t,n,i,r,Re.convert(o),Re.convert(l),a)}finally{const e=null!==M?ce.get(M).__webglFramebuffer:null;oe.bindFramebuffer(De.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);he.setTexture2D(t,0),De.copyTexSubImage2D(De.TEXTURE_2D,n,0,0,e.x,e.y,r,a),oe.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,a=t.image.height,s=Re.convert(n.format),o=Re.convert(n.type);he.setTexture2D(n,0),De.pixelStorei(De.UNPACK_FLIP_Y_WEBGL,n.flipY),De.pixelStorei(De.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),De.pixelStorei(De.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?De.texSubImage2D(De.TEXTURE_2D,i,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?De.compressedTexSubImage2D(De.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):De.texSubImage2D(De.TEXTURE_2D,i,e.x,e.y,s,o,t.image),0===i&&n.generateMipmaps&&De.generateMipmap(De.TEXTURE_2D),oe.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(y.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=Re.convert(i.format),c=Re.convert(i.type);let h;if(i.isData3DTexture)he.setTexture3D(i,0),h=De.TEXTURE_3D;else{if(!i.isDataArrayTexture&&!i.isCompressedArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");he.setTexture2DArray(i,0),h=De.TEXTURE_2D_ARRAY}De.pixelStorei(De.UNPACK_FLIP_Y_WEBGL,i.flipY),De.pixelStorei(De.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),De.pixelStorei(De.UNPACK_ALIGNMENT,i.unpackAlignment);const d=De.getParameter(De.UNPACK_ROW_LENGTH),u=De.getParameter(De.UNPACK_IMAGE_HEIGHT),p=De.getParameter(De.UNPACK_SKIP_PIXELS),f=De.getParameter(De.UNPACK_SKIP_ROWS),m=De.getParameter(De.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[r]:n.image;De.pixelStorei(De.UNPACK_ROW_LENGTH,g.width),De.pixelStorei(De.UNPACK_IMAGE_HEIGHT,g.height),De.pixelStorei(De.UNPACK_SKIP_PIXELS,e.min.x),De.pixelStorei(De.UNPACK_SKIP_ROWS,e.min.y),De.pixelStorei(De.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?De.texSubImage3D(h,r,t.x,t.y,t.z,a,s,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),De.compressedTexSubImage3D(h,r,t.x,t.y,t.z,a,s,o,l,g.data)):De.texSubImage3D(h,r,t.x,t.y,t.z,a,s,o,l,c,g),De.pixelStorei(De.UNPACK_ROW_LENGTH,d),De.pixelStorei(De.UNPACK_IMAGE_HEIGHT,u),De.pixelStorei(De.UNPACK_SKIP_PIXELS,p),De.pixelStorei(De.UNPACK_SKIP_ROWS,f),De.pixelStorei(De.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&De.generateMipmap(h),oe.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?he.setTextureCube(e,0):e.isData3DTexture?he.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?he.setTexture2DArray(e,0):he.setTexture2D(e,0),oe.unbindTexture()},this.resetState=function(){w=0,b=0,M=null,oe.reset(),Pe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return le}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===Q?"display-p3":"srgb",t.unpackColorSpace=Ue.workingColorSpace===$?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===K?q:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===q?K:J}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}(class extends rs{}).prototype.isWebGL1Renderer=!0;class as extends $t{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 ss{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=ae,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=me()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return console.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;io)continue;d.applyMatrix4(this.matrixWorld);const a=e.ray.origin.distanceTo(d);ae.far||t.push({distance:a,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,a.start),i=Math.min(f.count,a.start+a.count)-1;no)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);ie.far||t.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:s})}}class Js{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let a;a=t||e*n[r-1];let s,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),s=n[i]-a,s<0)o=i+1;else{if(!(s>0)){l=i;break}l=i-1}if(i=l,n[i]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),s=this.getPoint(r),o=t||(a.isVector2?new Me:new Qe);return o.copy(s).sub(a).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Qe,i=[],r=[],a=[],s=new Qe,o=new Rt;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Qe)}r[0]=new Qe,a[0]=new Qe;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(i[t-1],i[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(ge(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(s,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(ge(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Qs extends Js{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t){const n=t||new Me,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=i[(l-1)%r]:(eo.subVectors(i[0],i[1]).add(i[0]),s=eo);const h=i[l%r],d=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(ao(s,o.x,l.x,c.x,h.x),ao(s,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Pn(h,3)),this.setAttribute("normal",new Pn(d,3)),this.setAttribute("uv",new Pn(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new uo(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class po extends Bn{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e,t,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const s=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)a[i][e]=0===e&&i===r?s:s.clone().lerp(o,e/l)}for(let e=0;e.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Pn(r,3)),this.setAttribute("normal",new Pn(r.slice(),3)),this.setAttribute("uv",new Pn(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new po(e.vertices,e.indices,e.radius,e.details)}}class fo extends po{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fo(e.radius,e.detail)}}class mo extends po{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new mo(e.radius,e.detail)}}class go extends Bn{constructor(e=.5,t=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);const s=[],o=[],l=[],c=[];let h=e;const d=(t-e)/(i=Math.max(1,i)),u=new Qe,p=new Me;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=r+e/n*a;u.x=h*Math.cos(i),u.y=h*Math.sin(i),o.push(u.x,u.y,u.z),l.push(0,0,1),p.x=(u.x/t+1)/2,p.y=(u.y/t+1)/2,c.push(p.x,p.y)}h+=d}for(let e=0;e0)&&u.push(t,r,l),(e!==n-1||o0!=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}}class bo extends yn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new vn(16777215),this.specular=new vn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=o,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Mo extends yn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class To extends yn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new vn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Me(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=o,this.reflectivity=1,this.refractionRatio=.98,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.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function Eo(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Ao(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Ro(e,t,n){const i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){const i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function Co(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(t.push(a.time),n.push.apply(n,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(t.push(a.time),n.push(s)),a=e[r++]}while(void 0!==a)}class Po{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e=r)break e;{const s=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const e=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(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 n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&(s=i,ArrayBuffer.isView(s)&&!(s instanceof DataView)))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}var s;return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Y,r=e.length-1;let a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}No.prototype.TimeBufferType=Float32Array,No.prototype.ValueBufferType=Float32Array,No.prototype.DefaultInterpolation=X;class Oo extends No{}Oo.prototype.ValueTypeName="bool",Oo.prototype.ValueBufferType=Array,Oo.prototype.DefaultInterpolation=j,Oo.prototype.InterpolantFactoryMethodLinear=void 0,Oo.prototype.InterpolantFactoryMethodSmooth=void 0;class Uo extends No{}Uo.prototype.ValueTypeName="color";class Fo extends No{}Fo.prototype.ValueTypeName="number";class Bo extends Po{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t);let l=e*s;for(let e=l+s;l!==e;l+=4)Je.slerpFlat(r,0,a,l-s,a,l,o);return r}}class zo extends No{InterpolantFactoryMethodLinear(e){return new Bo(this.times,this.values,this.getValueSize(),e)}}zo.prototype.ValueTypeName="quaternion",zo.prototype.DefaultInterpolation=X,zo.prototype.InterpolantFactoryMethodSmooth=void 0;class ko extends No{}ko.prototype.ValueTypeName="string",ko.prototype.ValueBufferType=Array,ko.prototype.DefaultInterpolation=j,ko.prototype.InterpolantFactoryMethodLinear=void 0,ko.prototype.InterpolantFactoryMethodSmooth=void 0;class Ho extends No{}Ho.prototype.ValueTypeName="vector";class Vo{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=me(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(Go(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(No.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let e=0;e1){const e=a[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const a=[];for(const e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],s=[];Co(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==qo[e])return void qo[e].push({onLoad:t,onProgress:n,onError:i});qo[e]=[],qo[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=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 n=qo[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),a=r?parseInt(r):0,s=0!==a;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{Wo.add(e,t);const n=qo[e];delete qo[e];for(let e=0,i=n.length;e{const n=qo[e];if(void 0===n)throw this.manager.itemError(e),t;delete qo[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Jo extends Yo{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Wo.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const s=Re("img");function o(){c(),Wo.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(e),s.src=e,s}}class Qo extends Yo{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new ys,s=new Ko(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,(function(e){let n;try{n=r.parse(e)}catch(e){if(void 0===i)return void console.error(e);i(e)}void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:w,a.wrapT=void 0!==n.wrapT?n.wrapT:w,a.magFilter=void 0!==n.magFilter?n.magFilter:A,a.minFilter=void 0!==n.minFilter?n.minFilter:A,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace?a.colorSpace=n.colorSpace:void 0!==n.encoding&&(a.encoding=n.encoding),void 0!==n.flipY&&(a.flipY=n.flipY),void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=R),1===n.mipmapCount&&(a.minFilter=A),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)}),n,i),a}}class $o extends Yo{constructor(e){super(e)}load(e,t,n,i){const r=new je,a=new Jo(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)}),n,i),r}}class el extends $t{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new vn(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 tl=new Rt,nl=new Qe,il=new Qe;class rl{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Me(512,512),this.map=null,this.mapPass=null,this.matrix=new Rt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new wi,this._frameExtents=new Me(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;nl.setFromMatrixPosition(e.matrixWorld),t.position.copy(nl),il.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(il),t.updateMatrixWorld(),tl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(tl),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(tl)}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 al extends rl{constructor(){super(new di(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*fe*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class sl extends el{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy($t.DEFAULT_UP),this.updateMatrix(),this.target=new $t,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new al}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 ol=new Rt,ll=new Qe,cl=new Qe;class hl extends rl{constructor(){super(new di(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Me(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new Qe(1,0,0),new Qe(-1,0,0),new Qe(0,0,1),new Qe(0,0,-1),new Qe(0,1,0),new Qe(0,-1,0)],this._cubeUps=[new Qe(0,1,0),new Qe(0,1,0),new Qe(0,1,0),new Qe(0,1,0),new Qe(0,0,1),new Qe(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),ll.setFromMatrixPosition(e.matrixWorld),n.position.copy(ll),cl.copy(n.position),cl.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(cl),n.updateMatrixWorld(),i.makeTranslation(-ll.x,-ll.y,-ll.z),ol.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ol)}}class dl extends el{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new hl}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 ul extends rl{constructor(){super(new Ui(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class pl extends el{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy($t.DEFAULT_UP),this.updateMatrix(),this.target=new $t,this.shadow=new ul}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class fl extends el{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class ml extends el{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class gl{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n{t&&t(n),r.manager.itemEnd(e)})).catch((e=>{i&&i(e)})):(setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a);const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader;const o=fetch(e,s).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return Wo.add(e,n),t&&t(n),r.manager.itemEnd(e),n})).catch((function(t){i&&i(t),Wo.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)}));Wo.add(e,o),r.manager.itemStart(e)}}const _l="\\[\\]\\.:\\/",xl=new RegExp("["+_l+"]","g"),yl="[^"+_l+"]",Sl="[^"+_l.replace("\\.","")+"]",wl=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",yl)+/(WCOD+)?/.source.replace("WCOD",Sl)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yl)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yl)+"$"),bl=["material","materials","bones","map"];class Ml{constructor(e,t,n){this.path=t,this.parsedPath=n||Ml.parseTrackName(t),this.node=Ml.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Ml.Composite(e,t,n):new Ml(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(xl,"")}static parseTrackName(e){const t=wl.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==bl.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i{var t;switch(e.type){default:break;case"ambient":{const t=new fl(new vn(e.color),0);this._lightSources.push(t)}break;case"rectArea":{const n=new Qe(e.position.x,e.position.y,e.position.z);if(this.lightSourceScale&&n.length()this._scene.add(e)))}removeFromScene(){this._lightSources.forEach((e=>this._scene.remove(e)))}reload(){this.removeFromScene(),this.addToScene()}}Il.noLightSources=[],Il.defaultLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:3},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:3,z:2},color:"#ffffff",intensity:60,castShadow:!1}],Il.fifeLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:0},color:"#ffffff",intensity:40,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0}];const Nl={uniforms:{tDiffuse:{value:null},colorTransform:{value:new Rt},colorBase:{value:new Xe(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new Te}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = colorTransform * texture2D(tDiffuse, vUv) + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n gl_FragColor = color;\n }"},Ol=new Rt,Ul=(new Rt).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),Fl=(new Rt).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),Bl=(new Rt).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),zl=((new Rt).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1),(new Rt).set(0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1),(new Rt).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1)),kl=new Xe(0,0,0,0),Hl=new Xe(0,0,0,1),Vl=new Te,Gl=(new Te).set(1,0,0,0,-1,1,0,0,1),Wl=(e,t,n,i)=>(new Rt).set(e,0,0,1-e,0,t,0,1-t,0,0,n,1-n,0,0,0,i);var jl;!function(e){e[e.DEFAULT=0]="DEFAULT",e[e.ADDITIVE=1]="ADDITIVE"}(jl||(jl={}));class Xl extends ci{constructor(e,t=jl.ADDITIVE){const n=t===jl.ADDITIVE?{blendSrc:208,blendDst:200,blendEquation:s,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:s}:{};super(Object.assign({uniforms:li.clone(Nl.uniforms),vertexShader:Nl.vertexShader,fragmentShader:Nl.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1},n)),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const Yl={uniforms:{tDiffuse:{value:null},rangeMin:{value:new Me(1/512,1/512)},rangeMax:{value:new Me(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new Me(.1,.9),new Me(.1,.9);class ql extends ci{constructor(e){super({defines:Object.assign({},ql._linearDepthShader.defines),uniforms:li.clone(ql._linearDepthShader.uniforms),vertexShader:ql._linearDepthShader.vertexShader,fragmentShader:ql._linearDepthShader.fragmentShader,blending:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}ql._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new Xe(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include \n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};class Zl{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Kl=new Ui(-1,1,1,-1,0,1),Jl=new class extends Bn{constructor(){super(),this.setAttribute("position",new Pn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Pn([0,2,0,0,2,0],2))}};class Ql{constructor(e){this._mesh=new ni(Jl,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Kl)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class $l{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}dot4(e,t,n,i,r){return e[0]*t+e[1]*n+e[2]*i+e[3]*r}noise(e,t){let n,i,r;const a=(e+t)*(.5*(Math.sqrt(3)-1)),s=Math.floor(e+a),o=Math.floor(t+a),l=(3-Math.sqrt(3))/6,c=(s+o)*l,h=e-(s-c),d=t-(o-c);let u,p;h>d?(u=1,p=0):(u=0,p=1);const f=h-u+l,m=d-p+l,g=h-1+2*l,v=d-1+2*l,_=255&s,x=255&o,y=this.perm[_+this.perm[x]]%12,S=this.perm[_+u+this.perm[x+p]]%12,w=this.perm[_+1+this.perm[x+1]]%12;let b=.5-h*h-d*d;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[y],h,d));let M=.5-f*f-m*m;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[S],f,m));let T=.5-g*g-v*v;return T<0?r=0:(T*=T,r=T*T*this.dot(this.grad3[w],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s;const o=(e+t+n)*(1/3),l=Math.floor(e+o),c=Math.floor(t+o),h=Math.floor(n+o),d=1/6,u=(l+c+h)*d,p=e-(l-u),f=t-(c-u),m=n-(h-u);let g,v,_,x,y,S;p>=f?f>=m?(g=1,v=0,_=0,x=1,y=1,S=0):p>=m?(g=1,v=0,_=0,x=1,y=0,S=1):(g=0,v=0,_=1,x=1,y=0,S=1):fS?32:0)+(y>w?16:0)+(S>w?8:0)+(y>b?4:0)+(S>b?2:0)+(w>b?1:0),T=a[M][0]>=3?1:0,E=a[M][1]>=3?1:0,A=a[M][2]>=3?1:0,R=a[M][3]>=3?1:0,C=a[M][0]>=2?1:0,P=a[M][1]>=2?1:0,L=a[M][2]>=2?1:0,D=a[M][3]>=2?1:0,I=a[M][0]>=1?1:0,N=a[M][1]>=1?1:0,O=a[M][2]>=1?1:0,U=a[M][3]>=1?1:0,F=y-T+l,B=S-E+l,z=w-A+l,k=b-R+l,H=y-C+2*l,V=S-P+2*l,G=w-L+2*l,W=b-D+2*l,j=y-I+3*l,X=S-N+3*l,Y=w-O+3*l,q=b-U+3*l,Z=y-1+4*l,K=S-1+4*l,J=w-1+4*l,Q=b-1+4*l,$=255&m,ee=255&g,te=255&v,ne=255&_,ie=s[$+s[ee+s[te+s[ne]]]]%32,re=s[$+T+s[ee+E+s[te+A+s[ne+R]]]]%32,ae=s[$+C+s[ee+P+s[te+L+s[ne+D]]]]%32,se=s[$+I+s[ee+N+s[te+O+s[ne+U]]]]%32,oe=s[$+1+s[ee+1+s[te+1+s[ne+1]]]]%32;let le=.6-y*y-S*S-w*w-b*b;le<0?c=0:(le*=le,c=le*le*this.dot4(r[ie],y,S,w,b));let ce=.6-F*F-B*B-z*z-k*k;ce<0?h=0:(ce*=ce,h=ce*ce*this.dot4(r[re],F,B,z,k));let he=.6-H*H-V*V-G*G-W*W;he<0?d=0:(he*=he,d=he*he*this.dot4(r[ae],H,V,G,W));let de=.6-j*j-X*X-Y*Y-q*q;de<0?u=0:(de*=de,u=de*de*this.dot4(r[se],j,X,Y,q));let ue=.6-Z*Z-K*K-J*J-Q*Q;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(r[oe],Z,K,J,Q)),27*(c+h+d+u+p)}}const ec=new $o,tc=e=>{const t=new Uint8Array([Math.floor(255*e.r),Math.floor(255*e.g),Math.floor(255*e.b),255]),n=new ys(t,1,1);return n.needsUpdate=!0,n},nc=(e,t,n)=>{n&&e(tc(n)),t&&ec.load(t,e)};class ic{constructor(){this.bounds=new tt(new Qe(-1,-1,-1),new Qe(1,1,1)),this.size=new Qe(2,2,2),this.center=new Qe(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new Qe(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Ui?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof di&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),i=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const r=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),a=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=r/a,e.fov=be.radToDeg(2*Math.atan2(a,n)),e.near=n,e.far=i,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}const rc=e=>e.capabilities.maxSamples;class ac{changed(e){var t,n;const i=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),i}}const sc=e=>{const t=new $l,n=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),i=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,i=Array(n).fill(0);let r=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)-1===r&&a===t?(a=t-2,r=0):(a===t&&(a=0),r<0&&(r=t-1)),0===i[r*t+a]?(i[r*t+a]=e++,a++,r--):(a-=2,r++);return i})(n),r=i.length,a=new Uint8Array(4*r);for(let n=0;n{let t=hc[e];if(!t){switch(e){default:case 2:t=new So;break;case 0:t=new yo,t.opacity=.5;break;case 1:t=new So,t.transparent=!0,t.opacity=0;break;case 3:{const e=new wo;nc((t=>{uc(t),e.map=t}),"TexturesCom_Wood_ParquetChevron7_1K_albedo.jpg",new vn(1,.6,.2)),nc((t=>{uc(t),e.normalMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_normal.jpg"),nc((t=>{uc(t),e.roughnessMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_roughness.jpg"),e.aoMapIntensity=0,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}case 4:{const e=new wo;nc((t=>{uc(t),e.map=t}),"TexturesCom_Pavement_HerringboneNew_1K_albedo.jpg",new vn(.6,.3,0)),nc((t=>{uc(t),e.normalMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_normal.jpg"),nc((t=>{uc(t),e.roughnessMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_roughness.jpg"),nc((t=>{uc(t),e.aoMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_ao.jpg"),e.aoMapIntensity=1,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}}hc[e]=t}return t},uc=e=>{e.anisotropy=16,e.wrapS=S,e.wrapT=S,e.repeat.set(1e5,1e5)},pc=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new Me(t,n)};class fc{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new qe,this._colorRenderTarget}environmentMapDecodeTarget(e){var t;const n=e.capabilities.isWebGL2?D:C;return this._environmentMapDecodeTarget=null!==(t=this._environmentMapDecodeTarget)&&void 0!==t?t:new qe(1,1,{type:n}),this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new _c(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new _c(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Ui(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,i){var r;this.colorRenderTarget.setSize(n,i),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new ni(new Ti(2,2),new Sn({map:t}));const a=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const s=this.environmentMapDecodeTarget(e).texture,o=new Uint8Array(n*i*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,i,o),{texture:s,pixels:o,sRgbaPixels:!1}}newGrayscaleTexture(e,t,n,i){var r;const a=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name),s=this.environmentMapDecodeTarget(e);s.setSize(n,i),a.setSourceTexture(t),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new ni(new Ti(2,2),a);const o=e.getRenderTarget();e.setRenderTarget(s),e.render(this._planeMesh,this.camera),e.setRenderTarget(o);const l=s.texture,c=s.texture.type===D,h=c?new Float32Array(n*i*4):new Uint8Array(n*i*4);return e.readRenderTargetPixels(s,0,0,n,i,h),{texture:l,pixels:h,sRgbaPixels:c}}}const mc={tDiffuse:{value:null}},gc="\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",vc="\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }";class _c extends ci{constructor(e,t){super({uniforms:li.clone(mc),vertexShader:gc,fragmentShader:vc,defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}class xc{constructor(e){var t,n,i,r;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new je,pixels:new Uint8Array(0),sRgbaPixels:!1},this.detectorTexture=new je,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new Sc(0),this.lightSources=[],this._grayScale=new Qe(.2126,.7152,.0722),this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;npc(e)))}detectLightSources(e,t,n){var i;this.textureData=n,this._textureConverter=null!==(i=this._textureConverter)&&void 0!==i?i:new fc,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels,this.grayscaleTexture.sRgbaPixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort(((e,t)=>t.maxIntensity-e.maxIntensity))}_redFromRgbaToNormalizedFloatArray(e,t,n){const i=new Float32Array(e.length/4);let r=1,a=0;for(let t=0;te&&t.push(new yc(this.samplePoints[n],i))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let i=0;for(let e=Math.max(0,t-2);e1){l=!1;break}}else c=0}l&&(r.adjacent[a].push(s),r.adjacent[s].push(a),r.edges.push([a,s]))}return r}createLightSourcesFromLightGraph(e,t){const n=t.components.filter((e=>e.length>1)).map((t=>new wc(t.map((t=>e[t])))));return n.forEach((e=>e.calculateLightSourceProperties((e=>this._originalLuminanceValueFromUV(e))))),n}}class yc{constructor(e,t){this.position=e,this.uv=t}}class Sc{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;tt.length-e.length))}_dfs(e,t,n){t[e]=!0,n.push(e);for(const i of this.adjacent[e])t[i]||this._dfs(i,t,n)}}class wc{constructor(e){this.position=new Qe,this.uv=new Me,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new Qe,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=pc(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class bc{constructor(e){this._lightSourceDetector=e}static createPlane(e,t){const n=new Ti(2,1),i=null!=t?t:new Sn({color:12632256,side:2}),r=new ni(n,i);return r.position.z=-.1,e.add(r),r}createDebugScene(e,t){this._scene=e,this._createLightGraphInMap(this._lightSourceDetector.sampleUVs,this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph,t)}_createLightGraphInMap(e,t,n,i){const r=[],a=[];for(let e=0;ee.uv)),o=a.map((e=>e.uv)),l=e.filter((e=>!s.includes(e)&&!o.includes(e)));this._createSamplePointsInMap(l,.005,16711680),this._createSamplePointsInMap(s,.01,255),this._createSamplePointsInMap(o,.01,65280),this._createClusterLinesInMap(this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph.edges,128);const c=this._lightSourceDetector.lightSources.map((e=>e.uv));this._createSamplePointsInMap(c,.015,16776960);let h=this._lightSourceDetector.lightSources;void 0!==i&&i>=0&&i{var t;const n=new ni(i,r);n.position.copy(this._uvToMapPosition(e)),n.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(n)}))}_createCirclesInMap(e,t){const n=new Sn({color:t,transparent:!0,opacity:.5});e.forEach((e=>{var t;const i=new ho(e.size,8,4),r=new ni(i,n);r.position.copy(this._uvToMapPosition(e.uv)),r.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(r)}))}_createClusterLinesInMap(e,t,n){var i;const r=new Is({color:n}),a=[];t.forEach((t=>{for(let n=1;n.5){const e=(i.y+r.y)/2,t=i.x{(new Ko).setResponseType("arraybuffer").load(this._path+e,(e=>{this.parseData_(e),t(this._cubeTexture)}))}))}parseHeader_(e){const t=new DataView(e,0,30);this._size=t.getUint16(0),this._maxLod=t.getUint8(2),this._colorSpace=t.getUint16(3)?J:K,this._type=t.getUint16(5),this._format=t.getUint16(7),this._lightDirection.x=t.getFloat32(9),this._lightDirection.y=t.getFloat32(13),this._lightDirection.z=t.getFloat32(17)}parseBufferData_(e,t){let n=this._size;const i=Math.log2(this._size)+1;this._cubeTextures=[];for(let r=0;r{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function Lc(e){const t=new Sn;return t.color.setScalar(e),t}var Dc=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};try{URL.revokeObjectURL(Dc(""))}catch(e){Dc=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)}}var Ic=Uint8Array,Nc=Uint16Array,Oc=Uint32Array,Uc=new Ic([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]),Fc=new Ic([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]),Bc=new Ic([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zc=function(e,t){for(var n=new Nc(31),i=0;i<31;++i)n[i]=t+=1<>>1|(21845&Xc)<<1;Yc=(61680&(Yc=(52428&Yc)>>>2|(13107&Yc)<<2))>>>4|(3855&Yc)<<4,jc[Xc]=((65280&Yc)>>>8|(255&Yc)<<8)>>>1}var qc=function(e,t,n){for(var i=e.length,r=0,a=new Nc(t);r>>l]=c}else for(s=new Nc(i),r=0;r>>15-e[r]);return s},Zc=new Ic(288);for(Xc=0;Xc<144;++Xc)Zc[Xc]=8;for(Xc=144;Xc<256;++Xc)Zc[Xc]=9;for(Xc=256;Xc<280;++Xc)Zc[Xc]=7;for(Xc=280;Xc<288;++Xc)Zc[Xc]=8;var Kc=new Ic(32);for(Xc=0;Xc<32;++Xc)Kc[Xc]=5;var Jc=qc(Zc,9,1),Qc=qc(Kc,5,1),$c=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},eh=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},th=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},nh=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Ic(0);var r=!t||n,a=!n||n.i;n||(n={}),t||(t=new Ic(3*i));var s,o=function(e){var n=t.length;if(e>n){var i=new Ic(Math.max(2*n,e));i.set(t),t=i}},l=n.f||0,c=n.p||0,h=n.b||0,d=n.l,u=n.d,p=n.m,f=n.n,m=8*i;do{if(!d){n.f=l=eh(e,c,1);var g=eh(e,c+1,3);if(c+=3,!g){var v=e[(s=c,(R=(s/8|0)+(7&s&&1)+4)-4)]|e[R-3]<<8,_=R+v;if(_>i){if(a)throw"unexpected EOF";break}r&&o(h+v),t.set(e.subarray(R,_),h),n.b=h+=v,n.p=c=8*_;continue}if(1==g)d=Jc,u=Qc,p=9,f=5;else{if(2!=g)throw"invalid block type";var x=eh(e,c,31)+257,y=eh(e,c+10,15)+4,S=x+eh(e,c+5,31)+1;c+=14;for(var w=new Ic(S),b=new Ic(19),M=0;M>>4)<16)w[M++]=R;else{var P=0,L=0;for(16==R?(L=3+eh(e,c,3),c+=2,P=w[M-1]):17==R?(L=3+eh(e,c,7),c+=3):18==R&&(L=11+eh(e,c,127),c+=7);L--;)w[M++]=P}}var D=w.subarray(0,x),I=w.subarray(x);p=$c(D),f=$c(I),d=qc(D,p,1),u=qc(I,f,1)}if(c>m){if(a)throw"unexpected EOF";break}}r&&o(h+131072);for(var N=(1<>>4;if((c+=15&P)>m){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(F<256)t[h++]=F;else{if(256==F){U=c,d=null;break}var B=F-254;if(F>264){var z=Uc[M=F-257];B=eh(e,c,(1<>>4;if(!k)throw"invalid distance";if(c+=15&k,I=Wc[H],H>3&&(z=Fc[H],I+=th(e,c)&(1<m){if(a)throw"unexpected EOF";break}r&&o(h+131072);for(var V=h+B;he.length)&&(n=e.length);var i=new(e instanceof Nc?Nc:e instanceof Oc?Oc:Ic)(n-t);return i.set(e.subarray(t,n)),i}(t,0,h)},ih=new Ic(0);function rh(e,t){return nh((function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"}(e),e.subarray(2,-4)),t)}var ah,sh="undefined"!=typeof TextDecoder&&new TextDecoder;try{sh.decode(ih,{stream:!0})}catch(e){}class oh extends Qo{constructor(e){super(e),this.type=I}parse(e){const t=65536,n=14,i=65537,r=Math.pow(2.7182818,2.2),a={l:0,c:0,lc:0};function s(e,t,n,i,r){for(;n>n&(1<>6}const h={c:0,lc:0};function d(e,t,n,i){e=e<<8|H(n,i),t+=8,h.c=e,h.lc=t}const u={c:0,lc:0};function p(e,t,n,i,r,a,s,o,l){if(e==t){i<8&&(d(n,i,r,a),n=h.c,i=h.lc);let e=n>>(i-=8);if(e=new Uint8Array([e])[0],o.value+e>l)return!1;const t=s[o.value-1];for(;e-- >0;)s[o.value++]=t}else{if(!(o.value32767?t-65536:t}const g={a:0,b:0};function v(e,t){const n=m(e),i=m(t),r=n+(1&i)+(i>>1),a=r,s=r-i;g.a=a,g.b=s}function _(e,t){const n=f(e),i=f(t),r=n-(i>>1)&65535,a=i+r-32768&65535;g.a=a,g.b=r}function x(e,t,n,i,r,a,s){const o=s<16384,l=n>r?r:n;let c,h,d=1;for(;d<=l;)d<<=1;for(d>>=1,c=d,d>>=1;d>=1;){h=0;const s=h+a*(r-c),l=a*d,u=a*c,p=i*d,f=i*c;let m,x,y,S;for(;h<=s;h+=u){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p,i=r+l,a=i+p;o?(v(e[r+t],e[i+t]),m=g.a,y=g.b,v(e[n+t],e[a+t]),x=g.a,S=g.b,v(m,x),e[r+t]=g.a,e[n+t]=g.b,v(y,S),e[i+t]=g.a,e[a+t]=g.b):(_(e[r+t],e[i+t]),m=g.a,y=g.b,_(e[n+t],e[a+t]),x=g.a,S=g.b,_(m,x),e[r+t]=g.a,e[n+t]=g.b,_(y,S),e[i+t]=g.a,e[a+t]=g.b)}if(n&d){const n=r+l;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}if(r&d){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}c=d,d>>=1}return h}function y(e,t,r,f,m,g){const v=r.value,_=k(t,r),x=k(t,r);r.value+=4;const y=k(t,r);if(r.value+=4,_<0||_>=i||x<0||x>=i)throw new Error("Something wrong with HUF_ENCSIZE");const S=new Array(i),w=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(w),function(e,t,n,r,l,c){const h=t;let d=0,u=0;for(;r<=l;r++){if(h.value-t.value>n)return!1;s(6,d,u,e,h);const i=a.l;if(d=a.c,u=a.lc,c[r]=i,63==i){if(h.value-t.value>n)throw new Error("Something wrong with hufUnpackEncTable");s(8,d,u,e,h);let i=a.l+6;if(d=a.c,u=a.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let e=i-59+2;if(r+e>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)c[r++]=0;r--}}!function(e){for(let e=0;e<=58;++e)o[e]=0;for(let t=0;t0;--e){const n=t+o[e]>>1;o[e]=t,t=n}for(let t=0;t0&&(e[t]=n|o[n]++<<6)}}(c)}(e,r,f-(r.value-v),_,x,S),y>8*(f-(r.value-v)))throw new Error("Something wrong with hufUncompress");!function(e,t,i,r){for(;t<=i;t++){const i=c(e[t]),a=l(e[t]);if(i>>a)throw new Error("Invalid table entry");if(a>n){const e=r[i>>a-n];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n0;s--){const s=r[(i<=n;){const a=t[g>>v-n&16383];if(a.len)v-=a.len,p(a.lit,s,g,v,i,r,f,m,_),g=u.c,v=u.lc;else{if(!a.p)throw new Error("hufDecode issues");let t;for(t=0;t=n&&c(e[a.p[t]])==(g>>v-n&(1<>=y,v-=y;v>0;){const e=t[g<a||(t[r++]=e[n++],r>a));)t[r++]=e[i++]}function b(e){let t=e.byteLength;const n=new Array;let i=0;const r=new DataView(e);for(;t>0;){const e=r.getInt8(i++);if(e<0){const a=-e;t-=a+1;for(let e=0;e>8==255?r+=255&i:(n[r]=i,r++),e.value++}function T(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(.981746875),s=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),d=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=i*e[p+2],l[1]=s*e[p+2],l[2]=i*e[p+6],l[3]=s*e[p+6],c[0]=n*e[p+1]+r*e[p+3]+a*e[p+5]+o*e[p+7],c[1]=r*e[p+1]-o*e[p+3]-n*e[p+5]-a*e[p+7],c[2]=a*e[p+1]-n*e[p+3]+o*e[p+5]+r*e[p+7],c[3]=o*e[p+1]-a*e[p+3]+r*e[p+5]-n*e[p+7],h[0]=t*(e[p+0]+e[p+4]),h[3]=t*(e[p+0]-e[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[p+0]=d[0]+c[0],e[p+1]=d[1]+c[1],e[p+2]=d[2]+c[2],e[p+3]=d[3]+c[3],e[p+4]=d[3]-c[3],e[p+5]=d[2]-c[2],e[p+6]=d[1]-c[1],e[p+7]=d[0]-c[0]}for(let u=0;u<8;++u)l[0]=i*e[16+u],l[1]=s*e[16+u],l[2]=i*e[48+u],l[3]=s*e[48+u],c[0]=n*e[8+u]+r*e[24+u]+a*e[40+u]+o*e[56+u],c[1]=r*e[8+u]-o*e[24+u]-n*e[40+u]-a*e[56+u],c[2]=a*e[8+u]-n*e[24+u]+o*e[40+u]+r*e[56+u],c[3]=o*e[8+u]-a*e[24+u]+r*e[40+u]-n*e[56+u],h[0]=t*(e[u]+e[32+u]),h[3]=t*(e[u]-e[32+u]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[0+u]=d[0]+c[0],e[8+u]=d[1]+c[1],e[16+u]=d[2]+c[2],e[24+u]=d[3]+c[3],e[32+u]=d[3]-c[3],e[40+u]=d[2]-c[2],e[48+u]=d[1]-c[1],e[56+u]=d[0]-c[0]}function E(e){for(let t=0;t<64;++t){const n=e[0][t],i=e[1][t],r=e[2][t];e[0][t]=n+1.5747*r,e[1][t]=n-.1873*i-.4682*r,e[2][t]=n+1.8556*i}}function A(e,t,n){for(let a=0;a<64;++a)t[n+a]=Mn.toHalfFloat((i=e[a])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function R(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function C(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(b(t)),i=new Uint8Array(n.length);return S(n),w(n,i),new DataView(i.buffer)}function P(e){const t=rh(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return S(t),w(t,n),new DataView(n.buffer)}function L(e){const n=e.viewer,i={value:e.offset.value},r=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),a=new Uint8Array(8192);let s=0;const o=new Array(e.channels);for(let t=0;t=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let e=0;e>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const e=F(t.buffer,n),i=V(t,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=V(t,n);a.push({name:e,index:o,type:l,compression:r}),s-=e.length+3}const o=te.channels,l=new Array(e.channels);for(let t=0;t=0&&(c.idx[i.index]=t),e.offset=t)}}let h,d,u;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),y(e.array,t,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=rh(e.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const t={array:e.array,offset:n,size:r.dcCompressedSize};d=new Uint16Array(P(t).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(u=b(rh(e.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let e=0;e>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function Y(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function q(e,t){return X(Y(e,t))}function K(e,t,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(e,t,n){const i=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,i}(t,n,r):"chlist"===i?function(e,t,n,i){const r=n.value,a=[];for(;n.valuene.height?ne.height-t:ne.scanlineBlockSize;const n=ne.size=ne.height)break;for(let e=0;e(r=o.indexOf("\n"))&&a=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(c=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(a))&&(o.valid|=2,o.format=c[1]),(c=l.match(s))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(a),o=s.width,l=s.height,c=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);r!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const a=new Uint8Array(4*n*i);a.length||t(4,"unable to allocate buffer space");let s=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let d=i;for(;d>0&&oe.byteLength&&t(1),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])==r||t(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&t(3,"bad scanline data"),r){const t=e[o++];for(let e=0;e0?this.environmentName:r),s=this.currentEnvironment!==a;return this.showBackground=null!==(i=null==t?void 0:t.showEnvironment)&&void 0!==i&&i,this.currentEnvironment=a,this.currentEnvironment&&(null==t?void 0:t.environmentRotation)&&(this.currentEnvironment.rotation=t.environmentRotation),this.currentEnvironment&&(null==t?void 0:t.environmentIntensity)&&(this.currentEnvironment.intensity=t.environmentIntensity),e.userData.showEnvironmentBackground=this.showBackground,e.userData.environmentDefinition=this.currentEnvironment,s}loadDefaultEnvironment(e,t,n){var i;const r=null!=n?n:"room environment",a=null!==(i=t&&t())&&void 0!==i?i:new ch;this.environemtMap.set(r,new Rc(a)),e&&(this.environmentName=r),this.updateUI()}loadEnvmap(e,t,n){this.loadAndSetCubeTexture((t=>{this.environemtMap.set(e,new Rc(t)),n&&(this.environmentName=e),this.updateUI()}),t)}loadExr(e,t,n){this.loadExrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Rc(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadHdr(e,t,n){this.loadHdrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Rc(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadAndSetCubeTexture(e,t){t&&(this.envMapReader||(this.envMapReader=new Cc),this.envMapReader.load(t).then((t=>{t&&e(t)})))}loadExrAndSetTexture(e,t){t&&(this.exrLoader||(this.exrLoader=new oh),this.exrLoader.load(t,((t,n)=>{e(t,n)})))}loadHdrAndSetTexture(e,t){t&&(this.rgbeLoader||(this.rgbeLoader=new lh),this.rgbeLoader.load(t,((t,n)=>{e(t,n)})))}addGUI(e){this.uiFolder=e,this.updateUI()}updateUI(){if(this.uiFolder){const e=Array.from(this.environemtMap.keys());if(this.environmentController){let t="";e.forEach((e=>{t+=``})),this.environmentController.domElement.children[0].innerHTML=t,this.environmentController.setValue(this.environmentName),this.environmentController.updateDisplay()}else this.environmentController=this.uiFolder.add(this,"environmentName",e)}}}class dh extends ni{constructor(){const e=dh.SkyShader,t=new ci({name:e.name,uniforms:li.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:1,depthWrite:!1});super(new ri(1,1,1),t),this.isSky=!0}}dh.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new Qe},up:{value:new Qe(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPosition );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t}"};class uh{constructor(e){this.sky=new dh,this.sky.name="Sky",this.parameters=Object.assign({visible:!0,distance:4e5,turbidity:10,rayleigh:2,mieCoefficient:.005,mieDirectionalG:.8,inclination:.6,azimuth:0},e),this.updateSky()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateSky(){this.sky.scale.setScalar(45e4),this.sky.frustumCulled=!1,this.sky.material.uniforms.turbidity.value=this.parameters.turbidity,this.sky.material.uniforms.rayleigh.value=this.parameters.rayleigh,this.sky.material.uniforms.mieCoefficient.value=this.parameters.mieCoefficient,this.sky.material.uniforms.mieDirectionalG.value=this.parameters.mieDirectionalG;const e=(t=this.parameters.distance,n=this.parameters.azimuth,i=this.parameters.inclination,(new Qe).setFromSphericalCoords(t,Math.PI*(1-i),2*Math.PI*(1-n)));var t,n,i;this.sky.material.uniforms.sunPosition.value.copy(e),this.sky.visible=this.parameters.visible}addToScene(e){e.add(this.sky)}changeVisibility(e){this.parameters.visible!==e&&(this.updateParameters({visible:e}),this.updateSky())}}!function(e){e[e.None=0]="None",e[e.GridPaper=1]="GridPaper",e[e.Concrete=2]="Concrete",e[e.Marble=3]="Marble",e[e.Granite=4]="Granite",e[e.VorocracksMarble=5]="VorocracksMarble",e[e.Kraft=6]="Kraft",e[e.Line=7]="Line",e[e.Test=8]="Test"}(ah||(ah={}));class ph{get isSet(){return this.parameters.backgroundType!==ah.None}constructor(e){this._materialMap=new Map;const t=new Bn;t.setAttribute("position",new Pn([-1,3,0,-1,-1,0,3,-1,0],3)),t.setAttribute("uv",new Pn([0,2,0,0,2,0],2)),this.backgroundMesh=new ni(t),this.backgroundMesh.name="Background",this.parameters=Object.assign({visible:!1,backgroundType:ah.None},e),this.updateBackground()}_updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBackground(){this.backgroundMesh.visible=this.parameters.backgroundType!==ah.None,this.backgroundMaterial=this._getMaterial(),this.backgroundMesh.material=this.backgroundMaterial}update(e,t,n){this.backgroundMesh.visible&&this.backgroundMaterial&&(this.backgroundMaterial.uniforms.viewMatrixInverse.value.copy(n.matrixWorld),this.backgroundMaterial.uniforms.projectionMatrixInverse.value.copy(n.projectionMatrixInverse),this.backgroundMaterial.uniforms.iResolution.value.set(e,t))}addToScene(e){this.backgroundMesh!==e&&e.add(this.backgroundMesh)}hideBackground(){this.parameters.backgroundType!==ah.None&&(this.parameters.backgroundType=ah.None,this.updateBackground())}_getMaterial(){let e=this._materialMap.get(this.parameters.backgroundType);if(e)return e;let t=mh,n={};switch(this.parameters.backgroundType){default:break;case ah.Test:t=mh;break;case ah.GridPaper:t=gh;break;case ah.Concrete:t=vh,n={patternChoice:1};break;case ah.Marble:t=vh,n={patternChoice:3};break;case ah.Granite:t=vh,n={patternChoice:6};break;case ah.VorocracksMarble:t=_h;break;case ah.Kraft:t=xh;break;case ah.Line:t=yh}return e=new ci({name:"BackgroundShader",vertexShader:fh,fragmentShader:t,defines:n,uniforms:{viewMatrixInverse:{value:new Rt},projectionMatrixInverse:{value:new Rt},scale:{value:8},iResolution:{value:new Me(1024,1024)}},side:2,depthWrite:!1}),this._materialMap.set(this.parameters.backgroundType,e),e}}const fh="varying vec2 vertexUv;\nuniform mat4 viewMatrixInverse;\nuniform mat4 projectionMatrixInverse;\nuniform float scale;\n\nvoid main() {\n vec4 p = viewMatrixInverse * projectionMatrixInverse * vec4(position.xy, 0.0, 1.0);\n vertexUv = (p.xz / p.w * 0.5 + 0.5) / scale; \n gl_Position = vec4(position.xy, 1.0, 1.0);\n}",mh="varying vec2 vertexUv;\nvoid main() {\n vec2 uv = fract(vertexUv);\n gl_FragColor = vec4(uv.x, uv.y, (1.0-uv.x) * (1.0 - uv.y), 1.0);\n}",gh="varying vec2 vertexUv;\nuniform vec2 iResolution;\nfloat nsin(float a)\n{\n return (sin(a)+1.)/2.;\n}\nfloat rand(float n)\n{\n \treturn fract(cos(n*89.42)*343.42);\n}\nvec2 rand(vec2 n)\n{\n \treturn vec2(rand(n.x*23.62-300.0+n.y*34.35),rand(n.x*45.13+256.0+n.y*38.89)); \n}\n\n// returns (dx, dy, distance)\nvec3 worley(vec2 n,float s)\n{\n vec3 ret = vec3(s * 10.);\n // look in 9 cells (n, plus 8 surrounding)\n for(int x = -1;x<2;x++)\n {\n for(int y = -1;y<2;y++)\n {\n vec2 xy = vec2(x,y);// xy can be thought of as both # of cells distance to n, and \n vec2 cellIndex = floor(n/s) + xy;\n vec2 worleyPoint = rand(cellIndex);// random point in this cell (0-1)\n worleyPoint += xy - fract(n/s);// turn it into distance to n. ;\n float d = length(worleyPoint) * s;\n if(d < ret.z)\n ret = vec3(worleyPoint, d);\n }\n }\n return ret;\n}\n\nvec2 mouse = vec2(1.);// how do i initialize this??\n\nvec4 applyLighting(vec4 inpColor, vec2 uv, vec3 normal, vec3 LightPos, vec4 LightColor, vec4 AmbientColor)\n{\n // if(distance(uv.xy, LightPos.xy) < 0.01) return vec4(1.,0.,0.,1.);\n vec3 LightDir = vec3(LightPos.xy - uv, LightPos.z);\n vec3 N = normalize(normal);\n vec3 L = normalize(LightDir);\n vec3 Diffuse = (LightColor.rgb * LightColor.a) * max(dot(N, L), 0.0);\n vec3 Ambient = AmbientColor.rgb * AmbientColor.a;\n vec3 Intensity = Ambient + Diffuse;\n vec3 FinalColor = inpColor.rgb * Intensity;\n return vec4(FinalColor, inpColor.a);\n}\n\n// convert distance to alpha value (see https://www.shadertoy.com/view/ltBGzt)\nfloat dtoa(float d)\n{\n const float amount = 800.0;\n return clamp(1.0 / (clamp(d, 1.0/amount, 1.0)*amount), 0.,1.);\n}\n\n// distance to edge of grid line. real distance, and centered over its position.\nfloat grid_d(vec2 uv, vec2 gridSize, float gridLineWidth)\n{\n uv += gridLineWidth / 2.0;\n uv = mod(uv, gridSize);\n vec2 halfRemainingSpace = (gridSize - gridLineWidth) / 2.0;\n uv -= halfRemainingSpace + gridLineWidth;\n uv = abs(uv);\n uv = -(uv - halfRemainingSpace);\n return min(uv.x, uv.y);\n}\n// centered over lineposy\nfloat hline_d(vec2 uv, float lineposy, float lineWidth)\n{\n\treturn distance(uv.y, lineposy) - (lineWidth / 2.0);\n}\n// centered over lineposx\nfloat vline_d(vec2 uv, float lineposx, float lineWidth)\n{\n\treturn distance(uv.x, lineposx) - (lineWidth / 2.0);\n}\nfloat circle_d(vec2 uv, vec2 center, float radius)\n{\n\treturn length(uv - center) - radius;\n}\n\n// not exactly perfectly perfect, but darn close\nfloat pointRectDist(vec2 p, vec2 rectTL, vec2 rectBR)\n{\n float dx = max(max(rectTL.x - p.x, 0.), p.x - rectBR.x);\n float dy = max(max(rectTL.y - p.y, 0.), p.y - rectBR.y);\n return max(dx, dy);\n}\n\n\nvec2 getuv(vec2 fragCoord, vec2 newTL, vec2 newSize, out float distanceToVisibleArea, out float vignetteAmt)\n{\n vec2 ret = vec2(fragCoord.x / iResolution.x, (iResolution.y - fragCoord.y) / iResolution.y);// ret is now 0-1 in both dimensions\n \n // warp\n //ret = tvWarp(ret / 2.) * 2.;// scale it by 2.\n distanceToVisibleArea = pointRectDist(ret, vec2(0.0), vec2(1.));\n\n // vignette\n vec2 vignetteCenter = vec2(0.5, 0.5);\n\tvignetteAmt = 1.0 - distance(ret, vignetteCenter);\n vignetteAmt = 0.03 + pow(vignetteAmt, .25);// strength\n vignetteAmt = clamp(vignetteAmt, 0.,1.);\n \n \n ret *= newSize;// scale up to new dimensions\n float aspect = iResolution.x / iResolution.y;\n ret.x *= aspect;// orig aspect ratio\n float newWidth = newSize.x * aspect;\n return ret + vec2(newTL.x - (newWidth - newSize.x) / 2.0, newTL.y);\n}\n\nvec4 drawHole(vec4 inpColor, vec2 uv, vec2 pos)\n{\n vec4 circleWhiteColor = vec4(vec3(0.95), 1.);\n\tfloat d = circle_d(uv, pos, 0.055);\n return vec4(mix(inpColor.rgb, circleWhiteColor.rgb, circleWhiteColor.a * dtoa(d)), 1.);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n float distanceToVisibleArea;\n float vignetteAmt;\n\tvec2 uv = getuv(fragCoord, vec2(-1.,1.), vec2(2., -2.), distanceToVisibleArea, vignetteAmt);\n float throwaway;\n //mouse = getuv(iMouse.xy, vec2(-1.,1.), vec2(2., -2.), throwaway, throwaway);\n\n fragColor = vec4(0.94, 0.96, 0.78, 1.0);// background\n float d;\n \n // grid\n vec4 gridColor = vec4(0.2,0.4,.9, 0.35);\n\td = grid_d(uv, vec2(0.10), 0.001);\n\tfragColor = vec4(mix(fragColor.rgb, gridColor.rgb, gridColor.a * dtoa(d)), 1.);\n \n // red h line\n //vec4 hlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = hline_d(uv, 0.60, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, hlineColor.rgb, hlineColor.a * dtoa(d)), 1.);\n \n // red v line\n //vec4 vlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = vline_d(uv, -1.40, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, vlineColor.rgb, vlineColor.a * dtoa(d)), 1.);\n\n \n // fractal worley crumpled paper effect\n float wsize = 0.8;\n const int iterationCount = 6;\n vec2 normal = vec2(0.);\n float influenceFactor = 1.0;\n for(int i = 0; i < iterationCount; ++ i)\n {\n vec3 w = worley(uv, wsize);\n\t\tnormal.xy += influenceFactor * w.xy;\n wsize *= 0.5;\n influenceFactor *= 0.9;\n }\n \n // lighting\n //vec3 lightPos = vec3(mouse, 8.);\n //vec4 lightColor = vec4(vec3(0.99),0.6);\n //vec4 ambientColor = vec4(vec3(0.99),0.5);\n\t//fragColor = applyLighting(fragColor, uv, vec3(normal, 4.0), lightPos, lightColor, ambientColor);\n\n // white circles\n //fragColor = drawHole(fragColor, uv, vec2(-1.6, 0.2));\n\t//fragColor = drawHole(fragColor, uv, vec2(-1.6, -.7));\n \n // post effects\n\t//fragColor.rgb *= vignetteAmt;\n gl_FragColor = fragColor;\n}",vh="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n\n// Solid Colors\nvec3 red = vec3(1.0,0.0,0.0);\nvec3 green = vec3(0.0,1.0,0.0);\nvec3 blue = vec3(0.0,0.0,1.0);\nvec3 black = vec3(0.0,0.0,0.0);\nvec3 white = vec3(1.0,1.0,1.0);\n// Concrete\nvec3 concreteLite = vec3(0.909, 0.905, 0.917);\nvec3 concreteDark = vec3(0.760, 0.729, 0.647);\n// Lava\nvec3 lavaLite = vec3(0.686, 0.203, 0.160);\nvec3 lavaDark = vec3(0.580, 0.176, 0.117);\n// Marble\nvec3 marbleLite = vec3(0.988, 0.988, 0.988);\nvec3 marbleStainBlue1 = vec3(0.690, 0.760, 0.811);\nvec3 marbleStainBlue2 = vec3(0.647, 0.745, 0.803);\nvec3 marbleStainBlue3 = vec3(0.654, 0.756, 0.772);\n// Lava Lamp\nvec3 lavaLampBG = vec3(0.462, 0.266, 0.6);\nvec3 lavaLampLava = vec3(0.929, 0.203, 0.572);\n// Clouds\nvec3 sky = vec3(0.541, 0.729, 0.827);\nvec3 cloud = vec3(0.941, 0.945, 0.941);\n// Granite\nvec3 graniteBG = vec3(0.956, 0.952, 0.976);\nvec3 graniteGray = vec3(0.478, 0.474, 0.494);\nvec3 graniteBrown = vec3(0.4, 0.356, 0.341);\nvec3 graniteBlack = vec3(0.105, 0.121, 0.160);\n\n// Tartan\nvec3 tar1Blue = vec3(0.074, 0.349, 0.505);\nvec3 tar1Green = vec3(0.286, 0.541, 0.341);\nvec3 tar1White = vec3(1.0,1.0,1.0);\nvec3 tar1Black = vec3(0.0,0.0,0.0);\nvec3 tar1BG = vec3(0.062, 0.274, 0.109);\n\n// Tartan 2\nvec3 tar2BG = vec3(0.152, 0.160, 0.156);\nvec3 tar2Blue = vec3(0.176, 0.501, 0.674);\nvec3 tar2Orange = vec3(0.603, 0.407, 0.309);\n\n// Art Installation\nvec3 violet = vec3(0.662, 0.407, 0.870);\nvec3 yellow = vec3(0.968, 0.752, 0.556);\n\n\nfloat random (in vec2 uv) {\n return fract(sin(dot(uv.xy,\n vec2(12.9898,78.233)))*\n 43758.5453123);\n}\n\n// Based on Morgan McGuire @morgan3d\n// https://www.shadertoy.com/view/4dS3Wd\nfloat noise (in vec2 uv) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n\n // Four corners in 2D of a tile\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(a, b, u.x) +\n (c - a)* u.y * (1.0 - u.x) +\n (d - b) * u.x * u.y;\n}\n\n#define OCTAVES 6\nfloat fbm (in vec2 uv) {\n // Initial values\n float value = 0.0;\n float amplitud = .5;\n float frequency = 0.;\n //\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitud * noise(uv);\n uv *= 2.;\n amplitud *= .5;\n }\n return value;\n}\n\n// Simplex noise\nvec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); }\n\nfloat snoise(vec2 v) {\n const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439); // 1.0 / 41.0\n vec2 i = floor(v + dot(v, C.yy) );\n vec2 x0 = v - i + dot(i, C.xx);\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n i = mod289(i); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))\n + i.x + vec3(0.0, i1.x, 1.0 ));\n\n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m ;\n m = m*m ;\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n\nfloat lavaLamp(vec2 uv,vec2 shapePos, float times){\n shapePos = vec2(shapePos.x*1.5,shapePos.y*0.3);\n uv -= shapePos;\n \n float angle = atan(uv.y,uv.x);\n float radius = cos(times*angle*0.5);\n return radius;\n}\n\nvec4 rectangle(vec2 uv, vec2 pos, float width, float height, vec3 color) {\n\tfloat t = 0.0;\n\tif ((uv.x > pos.x - width / 2.0) && (uv.x < pos.x + width / 2.0)\n\t\t&& (uv.y > pos.y - height / 2.0) && (uv.y < pos.y + height / 2.0)) {\n\t\tt = 1.0;\n\t}\n\treturn vec4(color, t);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n\tvec2 uv = fragCoord.xy / iResolution.xy;\n\tfloat ratio = iResolution.x/iResolution.y;\n uv.x *= ratio;\n \n if (patternChoice == 1) // Concrete\n {\n vec3 value = concreteLite;\n \n value = mix(value, concreteDark,random(uv)*0.6);\n value = mix(value, black, random(uv)*0.35);\n \n vec3 stains = vec3(fbm((uv*5.)*2.))*.12;\n \n value = mix(value, concreteLite,(smoothstep(0.03,.12,stains) - smoothstep(.2,.3,stains))*0.3);\n \n\t fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 2) // Lava\n {\n\t\tvec3 value = black;\n \n vec3 stains = vec3(fbm((uv*1.7)*25.))*.75;\n \n float fade = sin(iTime * 5.)+2.5;\n \n value = mix(value, lavaLite, (smoothstep(0.05,0.1,stains) - smoothstep(.17, .22,stains) * fade));\n \n fragColor = vec4(value,1.0);\n }\n \n else if (patternChoice == 3) // Marble\n {\n vec3 value = marbleLite;\n \n vec3 stains = vec3(fbm((uv*1.2)*18.))*.113;\n vec3 stains2 = vec3(fbm((uv*5.)*1.5))*.12;\n \n vec3 stains3 = vec3(fbm((uv)*5.))*.12;\n vec3 stains4 = vec3(fbm((uv*2.)*2.5))*.12;\n \n value = mix(value, marbleStainBlue1,(smoothstep(0.065,0.1,stains) - smoothstep(0.1, 0.8,stains)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.065,0.1,stains2) - smoothstep(0.1, 0.8,stains2)));\n //value = mix(value, marbleStainBlue3,(smoothstep(0.09,0.1,stains2) - smoothstep(0.2, 0.5,stains2)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.07,0.1,stains3) - smoothstep(0.1, 0.8,stains3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 4) // Lava Lamp\n {\n //float value = lavaLamp(uv,vec2(0.,0.5), 3.);\n //vec2 value = vec2(snoise(uv*3.-iTime));\n \t//vec3 color = red*vec3(value, 1.0);\n \n vec3 value = lavaLampBG;\n float lava = lavaLamp(uv*0.5,vec2(snoise(uv*4.-iTime)), 1.);\n \n vec3 color = lavaLampLava*lava;\n value += color;\n \n \n fragColor = vec4(value, 1.0);\n }\n \t\n else if (patternChoice == 5) // Clouds\n {\n uv *= 0.5;\n vec3 value = sky;\n \n vec3 clouds = vec3(fbm((uv*sin(iTime*0.25))*20.))*.12;\n \n value = mix(value, cloud,(smoothstep(0.05,0.1,clouds) - smoothstep(0.1, 0.2,clouds)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 6) // Granite\n {\n \tvec3 value = graniteBG;\n \n uv *= 2.;\n uv += 2.3;\n vec3 layer1 = vec3(fbm((uv*0.6)*18.))*.113;\n uv *= 0.2;\n uv += 0.5;\n vec3 layer2 = vec3(fbm((uv*0.8)*30.))*.117;\n uv *= 2.2;\n uv += 2.5;\n vec3 layer3 = vec3(fbm((uv*0.4)*15.))*.12;\n \n value = mix(value, graniteBlack,(smoothstep(0.04,0.1,layer1) - smoothstep(0.1, 0.8,layer1)));\n value = mix(value, graniteBrown,(smoothstep(0.04,0.1,layer2) - smoothstep(0.1, 0.8,layer2)));\n value = mix(value, graniteGray,(smoothstep(0.072,0.1,layer3) - smoothstep(0.1, 0.8,layer3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 7) // Scottish Tartan 1\n {\n vec3 value = tar1BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float whiteTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // White lines\n // Vertical\n whiteTile += step(0.0001, uv.x) - step(0.02, uv.x);\n whiteTile += step(0.49, uv.x) - step(0.51, uv.x);\n // Horizontal\n whiteTile += step(0.220, uv.y) - step(0.245, uv.y);\n \twhiteTile += step(0.755, uv.y) - step(0.775, uv.y);\n \n // Black lines\n // Vertical\n blackTile += step(0.10, uv.x) - step(0.11, uv.x);\n blackTile += step(0.12, uv.x) - step(0.13, uv.x);\n blackTile += step(0.14, uv.x) - step(0.15, uv.x);\n blackTile += step(0.18, uv.x) - step(0.19, uv.x);\n blackTile += step(0.2, uv.x) - step(0.21, uv.x);\n blackTile += step(0.29, uv.x) - step(0.3, uv.x);\n blackTile += step(0.31, uv.x) - step(0.32, uv.x);\n blackTile += step(0.35, uv.x) - step(0.36, uv.x);\n blackTile += step(0.37, uv.x) - step(0.38, uv.x);\n blackTile += step(0.39, uv.x) - step(0.4, uv.x);\n blackTile += step(0.59, uv.x) - step(0.6, uv.x);\n blackTile += step(0.61, uv.x) - step(0.62, uv.x);\n blackTile += step(0.63, uv.x) - step(0.64, uv.x);\n blackTile += step(0.68, uv.x) - step(0.69, uv.x);\n blackTile += step(0.7, uv.x) - step(0.71, uv.x);\n blackTile += step(0.77, uv.x) - step(0.78, uv.x);\n blackTile += step(0.8, uv.x) - step(0.81, uv.x);\n blackTile += step(0.85, uv.x) - step(0.86, uv.x);\n blackTile += step(0.87, uv.x) - step(0.88, uv.x);\n blackTile += step(0.89, uv.x) - step(0.9, uv.x);\n // Horizontal\n blackTile += step(0.07, uv.y) - step(0.08, uv.y);\n blackTile += step(0.05, uv.y) - step(0.06, uv.y);\n blackTile += step(0.39, uv.y) - step(0.4, uv.y);\n blackTile += step(0.41, uv.y) - step(0.42, uv.y);\n blackTile += step(0.59, uv.y) - step(0.6, uv.y);\n blackTile += step(0.61, uv.y) - step(0.62, uv.y);\n blackTile += step(0.90, uv.y) - step(0.91, uv.y);\n blackTile += step(0.92, uv.y) - step(0.93, uv.y);\n \n // Apply\n value = mix(value, tar1Blue, vec3(blueTile * noise(uv* 1000.)));\n value = mix(value, tar1White, vec3(whiteTile * noise(uv * 200.)));\n value = mix(value, tar1Black, vec3(blackTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 8) // Scottish Tartan 2\n {\n vec3 value = tar2BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float orangeTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // Orange lines\n // Vertical\n orangeTile += step(0.0001, uv.x) - step(0.02, uv.x);\n orangeTile += step(0.49, uv.x) - step(0.51, uv.x);\n orangeTile += step(0.04, uv.x) - step(0.05, uv.x);\n orangeTile += step(0.97, uv.x) - step(0.98, uv.x);\n orangeTile += step(0.46, uv.x) - step(0.47, uv.x);\n orangeTile += step(0.53, uv.x) - step(0.54, uv.x);\n // Horizontal\n orangeTile += step(0.220, uv.y) - step(0.245, uv.y);\n \torangeTile += step(0.755, uv.y) - step(0.775, uv.y);\n orangeTile += step(0.200, uv.y) - step(0.210, uv.y);\n orangeTile += step(0.255, uv.y) - step(0.265, uv.y);\n orangeTile += step(0.730, uv.y) - step(0.740, uv.y);\n orangeTile += step(0.79, uv.y) - step(0.8, uv.y);\n \n // Apply\n value = mix(value, tar2Blue, vec3(blueTile * noise(uv* 1200.)));\n value = mix(value, tar2Orange, vec3(orangeTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 9) // Art Installation\n {\n vec2 uv2 = fragCoord.xy/iResolution.xy;\n uv2 -= 0.5;\n uv2.x *= 1.6;\n uv2.y *= 1.9;\n \n float dist = length(uv2);\n \n vec2 fragCo = fragCoord.xy;\n vec2 center = iResolution.xy * 0.5;\n float width = iResolution.x * 0.4;\n float height = iResolution.x * 0.2;\n \n vec3 value = mix(violet, yellow, dist);\n \n vec4 finalVal = vec4(value, 1.0);\n \n vec4 rect = rectangle(fragCo, center, width, height, violet);\n \n fragColor = mix(finalVal,rect,rect.a);\n fragColor = finalVal;\n }\n gl_FragColor = fragColor;\n}",_h="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n// variant of Vorocracks: https://shadertoy.com/view/lsVyRy\n// integrated with cracks here: https://www.shadertoy.com/view/Xd3fRN\n\n#define MM 0\n\n#define VARIANT 1 // 1: amplifies Voronoi cell jittering\n#if VARIANT\n float ofs = .5; // jitter Voronoi centers in -ofs ... 1.+ofs\n#else\n float ofs = 0.;\n#endif\n \n//int FAULT = 1; // 0: crest 1: fault\n\nfloat RATIO = 1., // stone length/width ratio\n /* STONE_slope = .3, // 0. .3 .3 -.3\n STONE_height = 1., // 1. 1. .6 .7\n profile = 1., // z = height + slope * dist ^ prof\n */ \n CRACK_depth = 3.,\n CRACK_zebra_scale = 1., // fractal shape of the fault zebra\n CRACK_zebra_amp = .67,\n CRACK_profile = 1., // fault vertical shape 1. .2 \n CRACK_slope = 50., // 10. 1.4\n CRACK_width = .0;\n \n\n// std int hash, inspired from https://www.shadertoy.com/view/XlXcW4\nvec3 hash3( uvec3 x ) \n{\n# define scramble x = ( (x>>8U) ^ x.yzx ) * 1103515245U // GLIB-C const\n scramble; scramble; scramble; \n return vec3(x) / float(0xffffffffU) + 1e-30; // <- eps to fix a windows/angle bug\n}\n\n// === Voronoi =====================================================\n// --- Base Voronoi. inspired by https://www.shadertoy.com/view/MslGD8\n\n#define hash22(p) fract( 18.5453 * sin( p * mat2(127.1,311.7,269.5,183.3)) )\n#define disp(p) ( -ofs + (1.+2.*ofs) * hash22(p) )\n\nvec3 voronoi( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), v;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, v = r;\n }\n\n return vec3( sqrt(m), v+u );\n}\n\n// --- Voronoi distance to borders. inspired by https://www.shadertoy.com/view/ldl3W8\nvec3 voronoiB( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), C, P;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, C = p-iu, P = r;\n }\n\n m = 1e9;\n \n for( int k=0; k < 25; k++ ) {\n vec2 p = iu+C + vec2(k%5-2,k/5-2),\n\t\t o = disp(p),\n r = p-u + o;\n\n if( dot(P-r,P-r)>1e-5 )\n m = min( m, .5*dot( (P+r), normalize(r-P) ) );\n }\n\n return vec3( m, P+u );\n}\n\n// === pseudo Perlin noise =============================================\n#define rot(a) mat2(cos(a),-sin(a),sin(a),cos(a))\nint MOD = 1; // type of Perlin noise\n \n// --- 2D\n#define hash21(p) fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453123)\nfloat noise2(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix(hash21(i+vec2(0,0)),hash21(i+vec2(1,0)),f.x),\n mix(hash21(i+vec2(0,1)),hash21(i+vec2(1,1)),f.x), f.y);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm2(vec2 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise2(p);\n\n return v;\n}\n#define noise22(p) vec2(noise2(p),noise2(p+17.7))\nvec2 fbm22(vec2 p) {\n vec2 v = vec2(0);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise22(p);\n\n return v;\n}\nvec2 mfbm22(vec2 p) { // multifractal fbm \n vec2 v = vec2(1);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n //v *= 1.+noise22(p);\n v += v * a * noise22(p);\n\n return v-1.;\n}\n\n/*\n// --- 3D \n#define hash31(p) fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123)\nfloat noise3(vec3 p) {\n vec3 i = floor(p);\n vec3 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix( mix(hash31(i+vec3(0,0,0)),hash31(i+vec3(1,0,0)),f.x),\n mix(hash31(i+vec3(0,1,0)),hash31(i+vec3(1,1,0)),f.x), f.y), \n mix( mix(hash31(i+vec3(0,0,1)),hash31(i+vec3(1,0,1)),f.x),\n mix(hash31(i+vec3(0,1,1)),hash31(i+vec3(1,1,1)),f.x), f.y), f.z);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm3(vec3 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p.xy *= R, p.yz *= R,\n v += a * noise3(p);\n\n return v;\n}\n*/\n \n// ======================================================\n\nvoid main()\n{\n vec4 O;\n vec2 U = vertexUv.xy * iResolution.yy;\n U *= 4./iResolution.y;\n U.x += iTime; // for demo\n // O = vec4( 1.-voronoiB(U).x,voronoi(U).x, 0,0 ); // for tests\n vec2 I = floor(U/2.); \n bool vert = mod(I.x+I.y,2.)==0.; //if (vert) U = U.yx;\n vec3 H0;\n O-=O;\n\n for(float i=0.; i{this.parse(e,t,i)}),n,i)}parse(e,t,n=(()=>{})){this.decodeDracoFile(e,t,null,null,K).catch(n)}decodeDracoFile(e,t,n,i,r=J,a=(()=>{})){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,s).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Sh.has(e)){const t=Sh.get(e);if(t.key===n)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 i;const r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((n=>(i=n,new Promise(((n,a)=>{i._callbacks[r]={resolve:n,reject:a},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),Sh.set(e,{key:n,promise:s}),s}_createGeometry(e){const t=new Bn;e.index&&t.setIndex(new An(e.index.array,1));for(let n=0;n{n.load(e,t,void 0,i)}))}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 n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=bh.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.lengtht._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_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{const t=e.draco,s=new t.Decoder;try{const e=function(e,t,i,r){const a=r.attributeIDs,s=r.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 a){const l=self[s[i]];let c,d;if(r.useUniqueIDs)d=a[i],c=t.GetAttributeByUniqueId(o,d);else{if(d=t.GetAttributeId(o,e[a[i]]),-1===d)continue;c=t.GetAttribute(o,d)}const u=n(e,t,o,i,l,c);"color"===i&&(u.vertexColorSpace=r.vertexColorSpace),h.attributes.push(u)}return c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const i=3*n.num_faces(),r=4*i,a=e._malloc(r);t.GetTrianglesUInt32Array(n,r,a);const s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,o)),e.destroy(o),h}(t,s,new Int8Array(i),a),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}}))}}}function Mh(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e=2.0 are supported.")));const l=new fd(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(a),l.setPlugins(s),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function Eh(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Ah={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_MATERIALS_BUMP:"EXT_materials_bump",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 Rh{constructor(e){this.parser=e,this.name=Ah.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class Hh{constructor(e){this.parser=e,this.name=Ah.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.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 Vh{constructor(e){this.parser=e,this.name=Ah.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.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 Gh{constructor(e){this.name=Ah.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=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 i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(t),a,s,o,e.mode,e.filter),t}))}))}return null}}class Wh{constructor(e){this.name=Ah.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==$h.TRIANGLES&&e.mode!==$h.TRIANGLE_STRIP&&e.mode!==$h.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,a=[],s={};for(const e in r)a.push(this.parser.getDependency("accessor",r[e]).then((t=>(s[e]=t,s[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new Rt,n=new Qe,a=new Je,o=new Qe(1,1,1),l=new Ds(e.geometry,e.material,i);for(let e=0;e-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new $o(this.options.manager):this.textureLoader=new vl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ko(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 n=this,i=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};return od(r,a,i),ld(a,i),Promise.all(n._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||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,h[e*a+1]),a>=3&&p.setZ(t,h[e*a+2]),a>=4&&p.setW(t,h[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);const n=(r.samplers||{})[a.sampler]||{};return t.magFilter=td[n.magFilter]||A,t.minFilter=td[n.minFilter]||R,t.wrapS=nd[n.wrapS]||S,t.wrapT=nd[n.wrapT]||S,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=n.images[e],a=self.URL||self.webkitURL;let s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new je(e);t.needsUpdate=!0,n(t)}),t.load(gl.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){var t;return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[Ah.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Ah.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(a);a=r.extensions[Ah.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Ws,yn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Is,yn.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||a){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return So}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const s={},o=[];if((r.extensions||{})[Ah.KHR_MATERIALS_UNLIT]){const e=i[Ah.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),o.push(e.extendParams(s,r,t))}else{const n=r.pbrMetallicRoughness||{};if(s.color=new vn(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],J),s.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(s,"map",n.baseColorTexture,K)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(s,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===r.doubleSided&&(s.side=2);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,"MASK"===l&&(s.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&a!==Sn&&(o.push(t.assignTexture(s,"normalMap",r.normalTexture)),s.normalScale=new Me(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==r.occlusionTexture&&a!==Sn&&(o.push(t.assignTexture(s,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(s.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&a!==Sn){const e=r.emissiveFactor;s.emissive=(new vn).setRGB(e[0],e[1],e[2],J)}return void 0!==r.emissiveTexture&&a!==Sn&&o.push(t.assignTexture(s,"emissiveMap",r.emissiveTexture,K)),Promise.all(o).then((function(){const n=new a(s);return r.name&&(n.name=r.name),ld(n,r),t.associations.set(n,{materials:e}),r.extensions&&od(i,n,r),n}))}createUniqueName(e){const t=Ml.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Ah.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return md(n,e,t)}))}const a=[];for(let n=0,s=e.length;n0&&cd(d,r),d.name=t.createUniqueName(r.name||"mesh_"+e),ld(d,r),h.extensions&&od(i,d,h),t.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n1?new Qa:1===t.length?t[0]:new $t,s!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of i.associations)(e instanceof yn||e instanceof je)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const a=[],s=e.name?e.name:e.uuid,o=[];let l;switch(ad[r.path]===ad.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(s),ad[r.path]){case ad.weights:l=Fo;break;case ad.rotation:l=zo;break;case ad.position:case ad.scale:l=Ho;break;default:l=1===n.itemSize?Fo:Ho}const c=void 0!==i.interpolation?sd[i.interpolation]:X,h=this._getArrayFromAccessor(n);for(let e=0,n=o.length;eMath.PI&&(_-=m),w<-Math.PI?w+=m:w>Math.PI&&(w-=m),s.theta=_<=w?Math.max(_,Math.min(w,s.theta)):s.theta>(_+w)/2?Math.max(_,s.theta):Math.min(w,s.theta)),s.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,s.phi)),s.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(c,n.dampingFactor):n.target.add(c),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&S||n.object.isOrthographicCamera?s.radius=I(s.radius):s.radius=I(s.radius*l),t.setFromSpherical(s),t.applyQuaternion(d),v.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(o.theta*=1-n.dampingFactor,o.phi*=1-n.dampingFactor,c.multiplyScalar(1-n.dampingFactor)):(o.set(0,0,0),c.set(0,0,0));let b=!1;if(n.zoomToCursor&&S){let i=null;if(n.object.isPerspectiveCamera){const e=t.length();i=I(e*l);const r=e-i;n.object.position.addScaledVector(x,r),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const e=new Qe(y.x,y.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),b=!0;const r=new Qe(y.x,y.y,0);r.unproject(n.object),n.object.position.sub(r).add(e),n.object.updateMatrixWorld(),i=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;null!==i&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(i).add(n.object.position):(xd.origin.copy(n.object.position),xd.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(xd.direction))a||8*(1-p.dot(n.object.quaternion))>a||f.distanceToSquared(n.target)>0)&&(n.dispatchEvent(gd),u.copy(n.object.position),p.copy(n.object.quaternion),f.copy(n.target),!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",Y),n.domElement.removeEventListener("pointerdown",V),n.domElement.removeEventListener("pointercancel",W),n.domElement.removeEventListener("wheel",j),n.domElement.removeEventListener("pointermove",G),n.domElement.removeEventListener("pointerup",W),null!==n._domElementKeyEvents&&(n._domElementKeyEvents.removeEventListener("keydown",X),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let r=i.NONE;const a=1e-6,s=new Rl,o=new Rl;let l=1;const c=new Qe,h=new Me,d=new Me,u=new Me,p=new Me,f=new Me,m=new Me,g=new Me,v=new Me,_=new Me,x=new Qe,y=new Me;let S=!1;const w=[],b={};function M(e){const t=Math.abs(e)/(100*(0|window.devicePixelRatio));return Math.pow(.95,n.zoomSpeed*t)}function T(e){o.theta-=e}function E(e){o.phi-=e}const A=function(){const e=new Qe;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),c.add(e)}}(),R=function(){const e=new Qe;return function(t,i){!0===n.screenSpacePanning?e.setFromMatrixColumn(i,1):(e.setFromMatrixColumn(i,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),c.add(e)}}(),C=function(){const e=new Qe;return function(t,i){const r=n.domElement;if(n.object.isPerspectiveCamera){const a=n.object.position;e.copy(a).sub(n.target);let s=e.length();s*=Math.tan(n.object.fov/2*Math.PI/180),A(2*t*s/r.clientHeight,n.object.matrix),R(2*i*s/r.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(A(t*(n.object.right-n.object.left)/n.object.zoom/r.clientWidth,n.object.matrix),R(i*(n.object.top-n.object.bottom)/n.object.zoom/r.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function P(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function L(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function D(e,t){if(!n.zoomToCursor)return;S=!0;const i=n.domElement.getBoundingClientRect(),r=e-i.left,a=t-i.top,s=i.width,o=i.height;y.x=r/s*2-1,y.y=-a/o*2+1,x.set(y.x,y.y,1).unproject(n.object).sub(n.object.position).normalize()}function I(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function N(e){h.set(e.clientX,e.clientY)}function O(e){p.set(e.clientX,e.clientY)}function U(e){if(1===w.length)h.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);h.set(n,i)}}function F(e){if(1===w.length)p.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);p.set(n,i)}}function B(e){const t=Z(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);g.set(0,r)}function z(e){if(1==w.length)d.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);d.set(n,i)}u.subVectors(d,h).multiplyScalar(n.rotateSpeed);const t=n.domElement;T(2*Math.PI*u.x/t.clientHeight),E(2*Math.PI*u.y/t.clientHeight),h.copy(d)}function k(e){if(1===w.length)f.set(e.pageX,e.pageY);else{const t=Z(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);f.set(n,i)}m.subVectors(f,p).multiplyScalar(n.panSpeed),C(m.x,m.y),p.copy(f)}function H(e){const t=Z(e),i=e.pageX-t.x,r=e.pageY-t.y,a=Math.sqrt(i*i+r*r);v.set(0,a),_.set(0,Math.pow(v.y/g.y,n.zoomSpeed)),P(_.y),g.copy(v),D(.5*(e.pageX+t.x),.5*(e.pageY+t.y))}function V(e){!1!==n.enabled&&(0===w.length&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener("pointermove",G),n.domElement.addEventListener("pointerup",W)),function(e){w.push(e.pointerId)}(e),"touch"===e.pointerType?function(e){switch(q(e),w.length){case 1:switch(n.touches.ONE){case 0:if(!1===n.enableRotate)return;U(e),r=i.TOUCH_ROTATE;break;case 1:if(!1===n.enablePan)return;F(e),r=i.TOUCH_PAN;break;default:r=i.NONE}break;case 2:switch(n.touches.TWO){case 2:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&B(e),n.enablePan&&F(e)}(e),r=i.TOUCH_DOLLY_PAN;break;case 3:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&B(e),n.enableRotate&&U(e)}(e),r=i.TOUCH_DOLLY_ROTATE;break;default:r=i.NONE}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(vd)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case 1:if(!1===n.enableZoom)return;!function(e){D(e.clientX,e.clientX),g.set(e.clientX,e.clientY)}(e),r=i.DOLLY;break;case 0:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;O(e),r=i.PAN}else{if(!1===n.enableRotate)return;N(e),r=i.ROTATE}break;case 2:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;N(e),r=i.ROTATE}else{if(!1===n.enablePan)return;O(e),r=i.PAN}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(vd)}(e))}function G(e){!1!==n.enabled&&("touch"===e.pointerType?function(e){switch(q(e),r){case i.TOUCH_ROTATE:if(!1===n.enableRotate)return;z(e),n.update();break;case i.TOUCH_PAN:if(!1===n.enablePan)return;k(e),n.update();break;case i.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;!function(e){n.enableZoom&&H(e),n.enablePan&&k(e)}(e),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;!function(e){n.enableZoom&&H(e),n.enableRotate&&z(e)}(e),n.update();break;default:r=i.NONE}}(e):function(e){switch(r){case i.ROTATE:if(!1===n.enableRotate)return;!function(e){d.set(e.clientX,e.clientY),u.subVectors(d,h).multiplyScalar(n.rotateSpeed);const t=n.domElement;T(2*Math.PI*u.x/t.clientHeight),E(2*Math.PI*u.y/t.clientHeight),h.copy(d),n.update()}(e);break;case i.DOLLY:if(!1===n.enableZoom)return;!function(e){v.set(e.clientX,e.clientY),_.subVectors(v,g),_.y>0?P(M(_.y)):_.y<0&&L(M(_.y)),g.copy(v),n.update()}(e);break;case i.PAN:if(!1===n.enablePan)return;!function(e){f.set(e.clientX,e.clientY),m.subVectors(f,p).multiplyScalar(n.panSpeed),C(m.x,m.y),p.copy(f),n.update()}(e)}}(e))}function W(e){!function(e){delete b[e.pointerId];for(let t=0;t0&&P(M(e.deltaY)),n.update()}(e),n.dispatchEvent(_d))}function X(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?E(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?E(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?T(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?T(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):C(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function Y(e){!1!==n.enabled&&e.preventDefault()}function q(e){let t=b[e.pointerId];void 0===t&&(t=new Me,b[e.pointerId]=t),t.set(e.pageX,e.pageY)}function Z(e){const t=e.pointerId===w[0]?w[1]:w[0];return b[t]}n.domElement.addEventListener("contextmenu",Y),n.domElement.addEventListener("pointerdown",V),n.domElement.addEventListener("pointercancel",W),n.domElement.addEventListener("wheel",j,{passive:!1}),this.update()}}const bd=new Tl,Md=new Qe,Td=new Qe,Ed=new Je,Ad={X:new Qe(1,0,0),Y:new Qe(0,1,0),Z:new Qe(0,0,1)},Rd={type:"change"},Cd={type:"mouseDown"},Pd={type:"mouseUp",mode:null},Ld={type:"objectChange"};class Dd extends $t{constructor(e,t){super(),void 0===t&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),t=document),this.isTransformControls=!0,this.visible=!1,this.domElement=t,this.domElement.style.touchAction="none";const n=new $d;this._gizmo=n,this.add(n);const i=new eu;this._plane=i,this.add(i);const r=this;function a(e,t){let a=t;Object.defineProperty(r,e,{get:function(){return void 0!==a?a:t},set:function(t){a!==t&&(a=t,i[e]=t,n[e]=t,r.dispatchEvent({type:e+"-changed",value:t}),r.dispatchEvent(Rd))}}),r[e]=t,i[e]=t,n[e]=t}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0);const s=new Qe,o=new Qe,l=new Je,c=new Je,h=new Qe,d=new Je,u=new Qe,p=new Qe,f=new Qe,m=new Qe;a("worldPosition",s),a("worldPositionStart",o),a("worldQuaternion",l),a("worldQuaternionStart",c),a("cameraPosition",h),a("cameraQuaternion",d),a("pointStart",u),a("pointEnd",p),a("rotationAxis",f),a("rotationAngle",0),a("eye",m),this._offset=new Qe,this._startNorm=new Qe,this._endNorm=new Qe,this._cameraScale=new Qe,this._parentPosition=new Qe,this._parentQuaternion=new Je,this._parentQuaternionInv=new Je,this._parentScale=new Qe,this._worldScaleStart=new Qe,this._worldQuaternionInv=new Je,this._worldScale=new Qe,this._positionStart=new Qe,this._quaternionStart=new Je,this._scaleStart=new Qe,this._getPointer=Id.bind(this),this._onPointerDown=Od.bind(this),this._onPointerHover=Nd.bind(this),this._onPointerMove=Ud.bind(this),this._onPointerUp=Fd.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.camera.isOrthographicCamera?this.camera.getWorldDirection(this.eye).negate():this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(e){if(void 0===this.object||!0===this.dragging)return;bd.setFromCamera(e,this.camera);const t=Bd(this._gizmo.picker[this.mode],bd);this.axis=t?t.object.name:null}pointerDown(e){if(void 0!==this.object&&!0!==this.dragging&&0===e.button&&null!==this.axis){bd.setFromCamera(e,this.camera);const t=Bd(this._plane,bd,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Cd.mode=this.mode,this.dispatchEvent(Cd)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let r=this.space;if("scale"===n?r="local":"E"!==t&&"XYZE"!==t&&"XYZ"!==t||(r="world"),void 0===i||null===t||!1===this.dragging||-1!==e.button)return;bd.setFromCamera(e,this.camera);const a=Bd(this._plane,bd,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),"translate"===n)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===r&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),"local"===r&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===r&&(i.position.applyQuaternion(Ed.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),"world"===r&&(i.parent&&i.position.add(Md.setFromMatrixPosition(i.parent.matrixWorld)),-1!==t.search("X")&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(Md.setFromMatrixPosition(i.parent.matrixWorld))));else if("scale"===n){if(-1!==t.search("XYZ")){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),Td.set(e,e,e)}else Md.copy(this.pointStart),Td.copy(this.pointEnd),Md.applyQuaternion(this._worldQuaternionInv),Td.applyQuaternion(this._worldQuaternionInv),Td.divide(Md),-1===t.search("X")&&(Td.x=1),-1===t.search("Y")&&(Td.y=1),-1===t.search("Z")&&(Td.z=1);i.scale.copy(this._scaleStart).multiply(Td),this.scaleSnap&&(-1!==t.search("X")&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===n){this._offset.copy(this.pointEnd).sub(this.pointStart);const e=20/this.worldPosition.distanceTo(Md.setFromMatrixPosition(this.camera.matrixWorld));let n=!1;"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Md.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(Ad[t]),Md.copy(Ad[t]),"local"===r&&Md.applyQuaternion(this.worldQuaternion),Md.cross(this.eye),0===Md.length()?n=!0:this.rotationAngle=this._offset.dot(Md.normalize())*e),("E"===t||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===r&&"E"!==t&&"XYZE"!==t?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Ed.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Ed.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Rd),this.dispatchEvent(Ld)}}pointerUp(e){0===e.button&&(this.dragging&&null!==this.axis&&(Pd.mode=this.mode,this.dispatchEvent(Pd)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}))}attach(e){return this.object=e,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Rd),this.dispatchEvent(Ld),this.pointStart.copy(this.pointEnd))}getRaycaster(){return bd}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function Id(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{const t=this.domElement.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*2-1,y:-(e.clientY-t.top)/t.height*2+1,button:e.button}}}function Nd(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}function Od(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function Ud(e){this.enabled&&this.pointerMove(this._getPointer(e))}function Fd(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}function Bd(e,t,n){const i=t.intersectObject(e,!0);for(let e=0;ee&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(kd.copy(qd).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(kd.copy(Zd).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(kd.copy(Zd).applyQuaternion(t).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(Ed.setFromEuler(zd.set(0,0,Math.PI/2)),i.quaternion.copy(t).multiply(Ed),Math.abs(kd.copy(qd).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(Ed.setFromEuler(zd.set(0,Math.PI/2,0)),i.quaternion.copy(t).multiply(Ed),Math.abs(kd.copy(Zd).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(Ed.setFromEuler(zd.set(0,Math.PI/2,0)),kd.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(Vd.lookAt(Hd,kd,qd)),i.quaternion.multiply(Ed),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),Md.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Md.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(Md),i.visible=this.dragging):(i.quaternion.copy(t),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(e)}}class eu extends ni{constructor(){super(new Ti(1e5,1e5,2,2),new Sn({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),Kd.copy(Yd).applyQuaternion("local"===t?this.worldQuaternion:Wd),Jd.copy(qd).applyQuaternion("local"===t?this.worldQuaternion:Wd),Qd.copy(Zd).applyQuaternion("local"===t?this.worldQuaternion:Wd),kd.copy(Jd),this.mode){case"translate":case"scale":switch(this.axis){case"X":kd.copy(this.eye).cross(Kd),jd.copy(Kd).cross(kd);break;case"Y":kd.copy(this.eye).cross(Jd),jd.copy(Jd).cross(kd);break;case"Z":kd.copy(this.eye).cross(Qd),jd.copy(Qd).cross(kd);break;case"XY":jd.copy(Qd);break;case"YZ":jd.copy(Kd);break;case"XZ":kd.copy(Qd),jd.copy(Jd);break;case"XYZ":case"E":jd.set(0,0,0)}break;default:jd.set(0,0,0)}0===jd.length()?this.quaternion.copy(this.cameraQuaternion):(Xd.lookAt(Md.set(0,0,0),jd,kd),this.quaternion.setFromRotationMatrix(Xd)),super.updateMatrixWorld(e)}}class tu{constructor(e,t,n){this.renderer=e,this.canvas=n||this.renderer.domElement,this.camera=t,this.orbitControls=new wd(t,this.canvas)}addTransformControl(e,t){const n=new Dd(this.camera,this.canvas);return n.addEventListener("dragging-changed",(e=>{this.orbitControls.enabled=!e.value})),n.attach(e),t.add(n),n}update(){this.orbitControls.update()}}class nu{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse((e=>{var t,n,i;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(i=this._cache)||void 0===i||i.addObject(e)})),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class iu{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach((e=>{e.dispose()}))}registerCache(e,t){this._cacheMap.set(e,new nu(t))}clearCache(){this._cacheMap.forEach((e=>{e.clear()}))}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const i=this._cacheMap.get(e);i&&(i.update(t),i.onBeforeRender()),n(),i&&i.onAfterRender()}}class ru{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=!1}))}onAfterRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=e}))}}class au{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof So&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!1}))}onAfterRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!0}))}}class su{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach(((e,t)=>{t instanceof ni&&t.material!==e.originalObjectData.material&&t.material!==e.updateObjectData.material&&(e.originalObjectData.material=t.material),this._updateObject(t,e.updateObjectData)}))}onAfterRender(){this._objectCache.forEach(((e,t)=>{this._updateObject(t,e.originalObjectData)}))}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof ni?e.receiveShadow:void 0,material:e instanceof ni?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof ni&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof ni&&void 0!==t.material&&(e.material=t.material)}}class ou extends ci{constructor(e){var t;super({defines:Object.assign(Object.assign(Object.assign({},ou._normalAndDepthShader.defines),{FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0})),uniforms:li.clone(ou._normalAndDepthShader.uniforms),vertexShader:ou._normalAndDepthShader.vertexShader,fragmentShader:ou._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}ou._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};class lu{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}updateGBufferRenderMaterial(e){var t;return this._gBufferRenderMaterial=null!==(t=this._gBufferRenderMaterial)&&void 0!==t?t:this.floatRgbNormalAlphaDepth?new ou({blending:0,floatBufferType:!0,linearDepth:!1}):new Mo({blending:0}),this._gBufferRenderMaterial instanceof ou&&this._gBufferRenderMaterial.update({camera:e}),this._gBufferRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatRgbNormalAlphaDepth)this._depthNormalRenderTarget=new qe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:D,samples:this._samples});else{const e=new sr(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=F,e.type=N,this._depthNormalRenderTarget=new qe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new qe(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:D,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,i,r,a,s,o,l,c,h,d;this.floatRgbNormalAlphaDepth=!1,this.linearDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.floatRgbNormalAlphaDepth=null!==(i=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==i&&i,this._renderCacheManager=e,this._renderCacheManager&&(this._gBufferMaterialCache=new cu,this._renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(r=null==t?void 0:t.depthNormalScale)&&void 0!==r?r:1},this._targetMinificationTextureFilter=null!==(a=null==t?void 0:t.textureMinificationFilter)&&void 0!==a?a:M,this._targetMagnificationTextureFilter=null!==(s=null==t?void 0:t.textureMagnificationFilter)&&void 0!==s?s:M,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(c=null==t?void 0:t.samples)&&void 0!==c?c:0,this._shared=null!==(h=null==t?void 0:t.shared)&&void 0!==h&&h,this._renderPass=null!==(d=null==t?void 0:t.renderPass)&&void 0!==d?d:new oc}dispose(){var e,t;null===(e=this._gBufferRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}render(e,t,n){this._shared&&!this.needsUpdate||(this.needsUpdate=!1,this._renderCacheManager?this._renderCacheManager.render(this,t,(()=>{this._renderGBuffer(e,t,n)})):this._renderGBuffer(e,t,n),this.floatRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget))}_renderGBuffer(e,t,n){this._renderPass.renderWithOverrideMaterial(e,t,n,this.updateGBufferRenderMaterial(n),this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new Xl),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:0,colorTransform:Fl,colorBase:Hl,multiplyChannels:0,uvTransform:Vl}),this.separateDeptRenderTarget)}}class cu extends su{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!0}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof yn&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof wo&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class hu extends ni{constructor(e,t){const n=new Sn({transparent:!0,depthWrite:!1});hu.alphaMap&&n.color.set(0),n.polygonOffset=!0,super(new Ti(1,1,10,10),n),this.name="ShadowGroundPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.setVisibilityLayers(e)}setVisibilityLayers(e){e?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;t.map=e,hu.alphaMap&&(t.alphaMap=e),t.needsUpdate=!0}updateMaterial(e){const t=this.material;e.opacity&&t.opacity!==e.opacity&&(t.opacity=e.opacity),e.polygonOffset&&t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset),t.needsUpdate=!0}}hu.alphaMap=!1;class du{get shadowGroundPlane(){var e;let t=this._sharedShadowGroundPlane;return t||(null!==(e=this._shadowGroundPlane)&&void 0!==e||(this._shadowGroundPlane=new hu(this.renderTarget.texture,this.parameters)),t=this._shadowGroundPlane),t.parent!==this._groundGroup&&this._groundGroup.add(t),t}constructor(e,t,n){var i;this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=t,this.shadowMapSize=null!==(i=n.shadowMapSize)&&void 0!==i?i:2048,this.parameters=this._getDefaultParameters(n),this._groundShadowFar=this.parameters.cameraFar,this._renderer=e,this._renderCacheManager=null==n?void 0:n.renderCacheManager,this._renderCacheManager&&this._renderCacheManager.registerCache(this,new ru((e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name)))),this.renderTarget=new qe(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new qe(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this._sharedShadowGroundPlane=null==n?void 0:n.sharedShadowGroundPlane,this.shadowGroundPlane.setShadowMap(this.renderTarget.texture),this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera=new uu,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new ja,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",hu.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=2,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new lc(Yl,n),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return Object.assign({enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:40,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0},e)}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFarthis.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibilityLayers(e){this.shadowGroundPlane.setVisibilityLayers(e)}render(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,e),!this.parameters.enabled)return;if(this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(e),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this._renderCacheManager?this._renderCacheManager.render(this,e,(()=>{this._renderer.render(e,this._groundContactCamera)})):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}du.addTestMesh=!1;class uu extends Ui{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,i,r;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new Ll(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(i=this.cameraHelper)||void 0===i?void 0:i.parent)&&(null===(r=this.cameraHelper)||void 0===r||r.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}const pu={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},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 float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},fu={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new Me(1/1024,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\t\tprecision highp float;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t\t//----------------------------------------------------------------------------------\n\t\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t\t// SDK Version: v3.00\n\t\t// Email: gameworks@nvidia.com\n\t\t// Site: http://developer.nvidia.com/\n\t\t//\n\t\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t\t//\n\t\t// Redistribution and use in source and binary forms, with or without\n\t\t// modification, are permitted provided that the following conditions\n\t\t// are met:\n\t\t// * Redistributions of source code must retain the above copyright\n\t\t// notice, this list of conditions and the following disclaimer.\n\t\t// * Redistributions in binary form must reproduce the above copyright\n\t\t// notice, this list of conditions and the following disclaimer in the\n\t\t// documentation and/or other materials provided with the distribution.\n\t\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t\t// contributors may be used to endorse or promote products derived\n\t\t// from this software without specific prior written permission.\n\t\t//\n\t\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t\t//\n\t\t//----------------------------------------------------------------------------------\n\n\t\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t\t#endif\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t\t/*--------------------------------------------------------------------------*/\n\n\t\t#define NUM_SAMPLES 5\n\n\t\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\t\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t\t}\n\n\t\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t\t============================================================================*/\n\n\t\t/*--------------------------------------------------------------------------*/\n\t\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t// locate the edge\n\t\t\t\tvec2 dirToEdge;\n\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t// . 2 . . 1 .\n\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t// . 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 H\n\n\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t// V 1 .\n\t\t\t\t// 0 0 1\n\t\t\t\t// . 0 .\n\n\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t// 1 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t// do a simple blur\n\t\t\t\t\treturn mix(\n\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t.4\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\titerationsUsed = i;\n\n\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\tif(!doneN) {\n\t\t\t\t\tnDist += increment;\n\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t}\n\n\t\t\t\tif(!doneP) {\n\t\t\t\t\tpDist += increment;\n\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t}\n\n\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\trgbaM,\n\t\t\t\trgbaN,\n\t\t\t\tdist * .5\n\t\t\t);\n\t\t}\n\n\t\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\tvUv,\n\t\t\t\ttDiffuse,\n\t\t\t\tresolution,\n\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t\t}\n\t"};class mu extends Zl{constructor(e,t,n,i,r){var a;super(),this.patternTexture=null,this._gBufferRenderTarget=null==r?void 0:r.gBufferRenderTarget,this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new vn(1,1,1),this.hiddenEdgeColor=new vn(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==r?void 0:r.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==r?void 0:r.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==e?new Me(e.x,e.y):new Me(256,256);const s=Math.round(this.resolution.x/this.downSampleRatio),o=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new qe(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this._gBufferRenderTarget||(this.depthMaterial=new ja,this.depthMaterial.side=2,this.depthMaterial.depthPacking=3201,this.depthMaterial.blending=0),this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this._gBufferRenderTarget||(this.renderTargetDepthBuffer=new qe(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new ci(fu),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new qe(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new qe(s,o),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new qe(s,o),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new qe(Math.round(s/2),Math.round(o/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new qe(s,o),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new qe(Math.round(s/2),Math.round(o/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(s,o),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(s/2),Math.round(o/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const l=pu;this.copyUniforms=li.clone(l.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ci({uniforms:this.copyUniforms,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new vn,this.oldClearAlpha=1,this.fsQuad=new Ql(void 0),this.tempPulseColor1=new vn,this.tempPulseColor2=new vn,this.textureMatrix=new Rt}dispose(){var e,t,n,i;this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),null===(t=this.renderTargetDepthBuffer)||void 0===t||t.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),null===(n=this.depthMaterial)||void 0===n||n.dispose(),this.prepareMaskMaterial.dispose(),null===(i=this.fxaaRenderMaterial)||void 0===i||i.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,i,r;this.renderTargetMaskBuffer.setSize(e,t),null===(n=this.renderTargetDepthBuffer)||void 0===n||n.setSize(e,t);let a=Math.round(e/this.downSampleRatio),s=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(a,s),this.renderTargetBlurBuffer1.setSize(a,s),this.renderTargetEdgeBuffer1.setSize(a,s),this.separableBlurMaterial1.uniforms.texSize.value.set(a,s),a=Math.round(a/2),s=Math.round(s/2),this.renderTargetBlurBuffer2.setSize(a,s),this.renderTargetEdgeBuffer2.setSize(a,s),this.separableBlurMaterial2.uniforms.texSize.value.set(a,s),null===(i=this.fxaaRenderMaterial)||void 0===i||i.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(r=this.renderTargetFxaaBuffer)||void 0===r||r.setSize(e,t)}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;function n(n){n.isMesh&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}this.selectedObjects.forEach((e=>e.traverse(n)))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];function i(e){e.isMesh&&n.push(e)}this.selectedObjects.forEach((e=>e.traverse(i))),this.renderScene.traverse((function(i){if(i.isMesh||i.isSprite){if(!1===n.some((e=>e.id===i.id))){const n=i.visible;!1!==e&&!0!==t.get(i)||(i.visible=e),t.set(i,n)}}else(i.isPoints||i.isLine)&&(!0===e?i.visible=t.get(i):(t.set(i,i.visible),i.visible=e))}))}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,r){var a,s;if(this.selectedObjects.length>0){null===(a=this._gBufferRenderTarget)||void 0===a||a.render(e,this.renderScene,this.renderCamera),e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const i=this.renderScene.background;this.renderScene.background=null,this.renderTargetDepthBuffer&&this.depthMaterial&&(this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera)),this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this._gBufferRenderTarget?this.prepareMaskMaterial.uniforms.depthTexture.value=this._gBufferRenderTarget.textureWithDepthValue:this.prepareMaskMaterial.uniforms.depthTexture.value=null===(s=this.renderTargetDepthBuffer)||void 0===s?void 0:s.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=i;let o=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),o=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=o.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=mu.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=mu.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=mu.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=mu.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=o.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}_getPrepareMaskMaterial(e){return new ci({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new Me(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include \n\t\t\t\t#include \n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new ci({uniforms:{maskTexture:{value:null},texSize:{value:new Me(.5,.5)},visibleEdgeColor:{value:new Qe(1,1,1)},hiddenEdgeColor:{value:new Qe(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new ci({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new Me(.5,.5)},direction:{value:new Me(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new ci({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}mu.BlurDirectionX=new Me(1,0),mu.BlurDirectionY=new Me(0,1);class gu{get isOutlinePassActivated(){return this.outlinePassActivated}constructor(e,t,n,i){this._width=0,this._height=0,this._effectComposer=null,this.outlinePass=null,this.outlinePassActivated=!1,this._effectComposer=e,this._gBufferRenderTarget=null==i?void 0:i.gBufferRenderTarget,this._width=t,this._height=n,this.parameters=Object.assign({enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215},i)}dispose(){var e;null===(e=this.outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this.outlinePass)||void 0===n||n.setSize(e,t)}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const i=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!i&&this.outlinePassActivated||(!i&&this.outlinePass||(this.outlinePass=new mu(new Me(this._width,this._height),e,t,[],{downSampleRatio:2,edgeDetectionFxaa:!0,gBufferRenderTarget:this._gBufferRenderTarget})),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}class vu extends zs{constructor(e,t){const n=new Bn;n.setAttribute("position",new Pn([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new Is({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Bn;i.setAttribute("position",new Pn([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new ni(i,new Sn({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class _u extends To{constructor(e){super(e),this.onBeforeCompile=this._onBeforeCompile}static setShadowParameters(e,t,n,i,r,a,s){this._enableGroundBoundary=e,_u._distributionProperties.set(t,n,i,r),_u._shadowFadeOut.set(a,s)}static setBoundingBox(e){_u._sceneBoxMin.copy(e.min),_u._sceneBoxMax.copy(e.max)}_onBeforeCompile(e,t){e.vertexShader=xu,e.fragmentShader=yu,e.defines=Object.assign(Object.assign(Object.assign({},e.defines),{DYNAMIC_SHADOW_RADIUS:"",GROUND_BOUNDARY:_u._enableGroundBoundary?1:0}));const n=e.uniforms;n&&(n.distributionProperties={value:_u._distributionProperties},n.shadowFadeOut={value:_u._shadowFadeOut},n.sceneBoxMin={value:_u._sceneBoxMin},n.sceneBoxMax={value:_u._sceneBoxMax})}}_u._enableGroundBoundary=!1,_u._shadowFadeOut=new Me(.1,20),_u._sceneBoxMin=new Qe(-1,-1,-1),_u._sceneBoxMax=new Qe(1,1,1),_u._distributionProperties=new Xe(1,1,1,1);const xu="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n #include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vWorldPosition = worldPosition.xyz;\n#else\n vWorldPosition = (modelMatrix * vec4(transformed, 1.)).xyz;\n#endif\n}\n",yu="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n #define fadeOutDistance shadowFadeOut.x\n #define fadeOutBlur shadowFadeOut.y\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n#define directionalDependency distributionProperties.x\n#define directionalExponent distributionProperties.y\n#define groundBoundary distributionProperties.z\n#define groundMapScale distributionProperties.w\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvec2 getShadowDynamicScale() {\n vec2 dynamicScale = vec2(0.0, 1.0);\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (fadeOutDistance > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n float shadowBase = clamp(boxDistance / fadeOutDistance, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n float dynamicRadius = shadowRadius;\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && fadeOutDistance > 0.0) {\n //float shadowDepth = unpackRGBAToDepth(texture2D(shadowMap, shadowCoord.xy));\n //float delta = shadowDepth - shadowCoord.z;\n //float fadeOutStart = delta / fadeOutDistance;\n //dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, max(shadowScale.x, fadeOutScale));\n dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, shadowScale.x);\n }\n#endif\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n vec2 dynamicScale = getShadowDynamicScale();\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n IncidentLight directLight;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float groundShadowFactor = 1.;\n float shadowFactor;\n float dynamicRadius;\n float dotNL;\n\n #pragma unroll_loop_start\n for ( int i = 0 ; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( GROUND_BOUNDARY == 1 && UNROLLED_LOOP_INDEX == 0 )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = fadeOutDistance * groundMapScale;\n groundShadowFactor = groundDistance < 0.5 ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0; \n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightSum += directLight.color;\n incidentShadowLight += directLight.color * mix(1.0, shadowFactor, pow(clamp(dotNL, 0.0, 1.0), directionalExponent));\n \n #endif\n }\n #pragma unroll_loop_end\n\n directionDependentShadowLight = incidentShadowLight / ( incidentLightSum + 1. - step(0., incidentLightSum) );\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(directionalDependency, 1.0 - groundDistance));\n #if GROUND_BOUNDARY == 1\n float groundWeight = 1. - groundShadowFactor + groundDistance - (1. - groundShadowFactor) * groundDistance;\n outgoingLight = mix(vec3(1.), outgoingLight, mix(dynamicScale.y, groundWeight, groundBoundary));\n #else\n outgoingLight = mix(vec3(1.), outgoingLight, dynamicScale.y);\n #endif\n\n\t#include \n\t#include \n}\n";var Su;!function(e){e[e.DirectionalLightShadow=0]="DirectionalLightShadow",e[e.SpotLightShadow=1]="SpotLightShadow"}(Su||(Su={}));const wu={alwaysUpdate:!1,enableShadowMap:!0,enableGroundBoundary:!0,layers:null,shadowLightSourceType:Su.DirectionalLightShadow,maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.1,fadeOutBlur:5};class bu{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var i,r;this.needsUpdate=!1,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new Ru,this._shadowLightSources=[],this._shadowScale=1,this._groundMapScale=1,this._renderPass=new oc,this._cameraUpdate=new ac,this._renderCacheManager=e,this._viewportSize=new Me(t.x,t.y),this._samples=null!==(i=null==n?void 0:n.samples)&&void 0!==i?i:0,this._shadowMapSize=null!==(r=null==n?void 0:n.shadowMapSize)&&void 0!==r?r:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new Au,this._renderCacheManager.registerCache(this,this._shadowMapPassOverrideMaterialCache);const a=this._samples;this._shadowRenderTarget=new qe(this._viewportSize.x,this._viewportSize.y,{samples:a,format:B})}_getScreenSpaceShadowMapParameters(e){return Object.assign(Object.assign({},wu),e)}dispose(){this._shadowLightSources.forEach((e=>e.dispose())),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){var n;const i=this._shadowScale;if(this._shadowScale=t,Math.abs(i-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach((t=>t.updateBounds(e))),this._shadowLightSources.length>0){const e=null===(n=this._shadowLightSources[0].getShadowLight().shadow)||void 0===n?void 0:n.camera;e instanceof Ui&&(this._groundMapScale=2*this._shadowMapSize/(Math.abs(e.right-e.left)+Math.abs(e.top-e.bottom)))}else this._groundMapScale=1;this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach((e=>e.forceShadowUpdate())),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map((e=>e.getShadowLight()))}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find((t=>t.getOriginalLight()===e)))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new Pu(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){this._shadowLightSources=this._shadowLightSources.filter((n=>{if(n instanceof Pu){const t=n.getRectAreaLight();if(e.includes(t))return n.updatePositionAndTarget(),!0}return n.removeFrom(t),n.dispose(),!1})),e.forEach((e=>{this._shadowLightSources.find((t=>t instanceof Pu&&t.getRectAreaLight()===e))||this.addRectAreaLight(e,t)})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){this._shadowLightSources=this._shadowLightSources.filter((t=>{t.removeFrom(e),t.dispose()}));const n=1/(t.length>0?Math.max(...t.map((e=>e.maxIntensity))):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach((t=>{t.addTo(e),t.updatePositionAndTarget()})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){const n=new Du(new Qe(0,7,0),{shadowMapSize:this._shadowMapSize});this._shadowLightSources.push(n),e.forEach((e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new Qe(e.position.x,e.position.z,e.position.y).multiplyScalar(7),i=new Lu(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(i)}}))}setSize(e,t){this._viewportSize=new Me(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach((e=>e.updatePositionAndTarget()))}renderShadowMap(e,t,n){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(n)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const i=t.background,r=t.environment,a=n.layers.mask;t.environment=null,t.background=null,this.parameters.layers&&(n.layers.mask=this.parameters.layers.mask),this._renderSimpleShadowMapFromShadowLightSources(e,t,n),n.layers.mask=a,t.environment=r,t.background=i}_renderSimpleShadowMapFromShadowLightSources(e,t,n){this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.enableGroundBoundary,this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundBoundary,this._groundMapScale,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const i=this._getSortedShadowLightSources();0===i.length?this._renderPass.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(i),this._renderCacheManager.render(this,t,(()=>{this._renderPass.render(e,t,n,this._shadowRenderTarget,16777215,1)})),this._shadowLightSources.forEach((e=>e.finishRenderShadow())))}_getSortedShadowLightSources(){const e=[];return this._shadowLightSources.forEach((t=>e.push(...t.prepareRenderShadow()))),e.sort(((e,t)=>e.light.castShadow&&!t.light.castShadow||e.groundShadow&&!t.groundShadow?-1:!e.light.castShadow&&t.light.castShadow||!e.groundShadow&&t.groundShadow?1:t.intensity-e.intensity)),e}_setShadowLightSourcesIntensity(e){let t=0;const n=this.parameters.maximumNumberOfLightSources;let i=0;e.forEach((e=>{(n<0||i{var r;!this.parameters.enableGroundBoundary&&e.groundShadow||!(n<0||ie._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale)))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}var Mu,Tu,Eu;!function(e){e[e.Default=0]="Default",e[e.Unlit=1]="Unlit",e[e.Emissive=2]="Emissive",e[e.Shadow=3]="Shadow"}(Mu||(Mu={}));class Au extends su{set shadowOnGround(e){this._shadowOnGround=e}constructor(){super(),this._boundingBoxSet=!1,this._shadowOnGround=!0,this._shadowObjectMaterial=this._createShadowMaterial(Mu.Default),this._unlitMaterial=this._createShadowMaterial(Mu.Unlit),this._emissiveMaterial=this._createShadowMaterial(Mu.Emissive),this._receiveShadowMaterial=this._createShadowMaterial(Mu.Shadow)}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,i,r,a,s){_u.setShadowParameters(e,t,n,i,r,a,s)}setBoundingBox(e){this._boundingBoxSet=!0,_u.setBoundingBox(e)}_createShadowMaterial(e){let t;return t=e===Mu.Emissive||e===Mu.Unlit?new Sn({color:16777215,side:2}):e===Mu.Shadow?new yo({side:2}):Au.useModifiedMaterial?this._createCustomerShadowMaterial():new bo({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:2}),t}_createCustomerShadowMaterial(){return new _u({side:2})}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof Is||t instanceof Sn?this.addToCache(e,{material:this._unlitMaterial}):t instanceof So?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}Au.useModifiedMaterial=!0;class Ru{constructor(){var e;this.types=new Map([["off",Ru._noShadow],["BasicShadowMap",Ru._basicShadow],["PCFShadowMap",Ru._pcfShadow],["PCFSoftShadowMap",Ru._pcfSoftShadow],["VSMShadowMap",Ru._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:Ru._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:Ru._defaultType,!0)}}Ru._noShadow={castShadow:!1,type:i,bias:0,normalBias:0,radius:0},Ru._basicShadow={castShadow:!0,type:0,bias:-5e-5,normalBias:.005,radius:0},Ru._pcfShadow={castShadow:!0,type:i,bias:-5e-5,normalBias:.01,radius:4},Ru._pcfSoftShadow={castShadow:!0,type:r,bias:-5e-5,normalBias:.01,radius:1},Ru._vcmShadow={castShadow:!0,type:a,bias:1e-4,normalBias:0,radius:15},Ru._defaultType=Ru._pcfShadow;class Cu{constructor(e,t){var n,i;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(i=null==t?void 0:t.blurSamples)&&void 0!==i?i:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new Me(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new Qe(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof sl){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),i=Math.max(.001,Math.min(-n.min.z,-n.max.z)),r=Math.max(-n.min.z,-n.max.z),a=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),s=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(s,a),i);t.aspect=1,t.near=i,t.far=r,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,i,r;if(this._shadowLightSource instanceof sl){const n=t.clone().sub(e),i=n.length();n.normalize();const r=t.clone().sub(n.clone().multiplyScalar(4*i));this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(r),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.lookAt(t);null===(r=this._shadowLightSource.shadow)||void 0===r||r.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class Pu extends Cu{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case Su.DirectionalLightShadow:n=new pl(16777215,1);break;case Su.SpotLightShadow:n=new sl(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new vu(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity,groundShadow:!1}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class Lu extends Cu{constructor(e,t,n){const i=new pl(16777215,t);i.position.copy(e),i.lookAt(0,0,0),i.updateMatrix(),i.castShadow=!0,super(i,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity,groundShadow:!1}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}class Du extends Cu{constructor(e,t){const n=new pl(16777215,1);n.position.copy(e),n.lookAt(0,0,0),n.updateMatrix(),n.castShadow=!0,super(n,t),this._position=e.clone()}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:1,groundShadow:!0}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}!function(e){e[e.INPUT_RGB_NORMAL=0]="INPUT_RGB_NORMAL",e[e.FLOAT_BUFFER_NORMAL=1]="FLOAT_BUFFER_NORMAL",e[e.CONSTANT_Z=2]="CONSTANT_Z"}(Tu||(Tu={})),function(e){e[e.SEPARATE_BUFFER=0]="SEPARATE_BUFFER",e[e.NORMAL_VECTOR_ALPHA=1]="NORMAL_VECTOR_ALPHA"}(Eu||(Eu={}));const Iu=(e,t)=>{const n=Nu(e,t);let i="vec4[SAMPLES](";for(let t=0;t{const n=[];for(let i=0;i\n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\t#if DEPTH_BUFFER_ANTIALIAS == 1\n\t\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\t\tivec2 p = ivec2(uv * size);\n\t\t\t\tfloat d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n\t\t\t\tvec2 depth = vec2(d0, 1.0);\n\t\t\t\tfloat d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n\t\t\t\tfloat d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n\t\t\t\tfloat d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n\t\t\t\tfloat d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n\t\t\t\treturn depth.x / depth.y;\n \t#else\n \treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n \t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\t#if NORMAL_VECTOR_ANTIALIAS == 1\n\t\t\t\t\tvec2 uv = screenPosition;\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tfloat c0 = texelFetch(tNormal, p, 0).a;\n\t\t\t\t\tfloat l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t\t\t#elif NORMAL_VECTOR_ANTIALIAS == 2\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tvec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n\t\t\t\t\treturn normalize(normalVector);\n\t\t\t\t#else\n\t\t\t\t\treturn texture2D(tNormal, screenPosition).xyz;\n\t\t\t\t#endif\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(screenPosition);\n\t\t\t#endif\n\t\t }\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\n\t\tfloat sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n\t\t\tvec3 delta = point - pointOnPlane;\n\t\t\tfloat sinV = dot(planeNormal, normalize(delta));\n\t\t\treturn sinV;\n\t\t}\n\n\t\tfloat getFallOff(float delta, float falloffDistance) {\n\t\t\tfloat fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n\t\t\treturn fallOff;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n \t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n\t\t\t#if NV_ALIGNED_SAMPLES == 1\n \t\t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#elif AO_ALGORITHM == 3\n\t\t\tconst int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#else\n\t\t\tconst int DIRECTIONS = SAMPLES;\n\t\t\tconst int STEPS = 1;\n\t\t#endif\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\n\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#elif AO_ALGORITHM == 3\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * 2. * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#else\n\t\t\t\tvec4 sampleDir = sampleKernel[i];\n\t\t\t#endif\n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t#else\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n\t\t\t\t#endif\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleViewOffset;\n\t\t\t#else\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n\t\t\t#endif\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tfloat sceneSampleDist = abs(sampleSceneViewPos.z);\n\t\t\t\t\tfloat sampleDist = abs(sampleViewPos.z);\n\t\t\t\t\t\n\t\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\t\t// HBAO || GTAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));\n\t\t\t\t\t}\t\t\n\t\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));\t\n\t\t\t\t\t\t}\n\t\t\t\t\t#endif\n\t\t\t\t#elif AO_ALGORITHM == 2\n\t\t\t\t\t// N8AO\n\t\t\t\t\tfloat weight = dot(viewNormal, sampleDir.xyz);\n\t\t\t\t\tfloat occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#elif AO_ALGORITHM == 1\n\t\t\t\t\t// SAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tfloat minResolution = 0.; // ?\n\t\t\t\t\tfloat scaledViewDist = length( viewDelta ) / scale;\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n\t\t\t\t#else\n\t\t\t\t\t// SSAO\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\t\n\t\t\t\t}\n\t\t\t\t// GTAO\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\n\t\t#elif AO_ALGORITHM == 3\n\t\t\t\t}\n\t\t\t\ttotalWeight += 1.;\n\t\t\t\tao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#else\n\n\t\t\t\tfloat fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n\t\t\t\tocclusion *= fallOff;\n\t\t\t\tvec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n\t\t\t\tocclusion *= step(1., dot(diff, diff));\n\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\tocclusion *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\tweight *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\ttotalWeight += weight;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#endif\t\n\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t#if AO_ALGORITHM != 1\n\t\t\tao = pow(ao, scale);\n\t\t#endif\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},Uu={resolutionScale:1,algorithm:0,samples:32,radius:.25,distanceExponent:2,thickness:.5,distanceFallOff:.5,scale:1,bias:.01,screenSpaceRadius:!1};class Fu{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n){this.needsUpdate=!0,this.parameters=Object.assign({},Uu),this._width=0,this._height=0,this._normalVectorSourceType=Tu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=Eu.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._renderPass=new oc,this._sceneClipBox=new tt(new Qe(-1,-1,-1),new Qe(1,1,1)),this._sceneScale=1,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Tu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||Eu.NORMAL_VECTOR_ALPHA,this._modulateRedChannel=(null==n?void 0:n.modulateRedChannel)||!1,(null==n?void 0:n.aoParameters)&&(this.parameters=n.aoParameters),n&&this.updateTextures(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new $l,n=new Uint8Array(e*e*4);for(let i=0;i{const i=zu(e,t,n);let r="vec3[SAMPLES](";for(let t=0;t{const i=[];for(let r=0;r\n#include \n\n#ifndef LUMINANCE_TYPE\n#define LUMINANCE_TYPE float\n#endif\n\n#ifndef SAMPLE_LUMINANCE\n#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n#endif\n\n#ifndef FRAGMENT_OUTPUT\n#define FRAGMENT_OUTPUT vec4(denoised, 1.)\n#endif\n\nLUMINANCE_TYPE getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n}\n\nconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n}\n\nfloat getDepth(const vec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return textureLod(tDepth, uv.xy, 0.0).a;\n#else\n return textureLod(tDepth, uv.xy, 0.0).r;\n#endif\n}\n\nfloat fetchDepth(const ivec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return texelFetch(tDepth, uv.xy, 0).a;\n#else\n return texelFetch(tDepth, uv.xy, 0).r;\n#endif\n}\n\nvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nvec3 getViewNormal(const vec2 uv) {\n#if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n#elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n#else\n return computeNormalFromDepth(uv);\n#endif\n}\n\nvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout LUMINANCE_TYPE totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n \n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n LUMINANCE_TYPE lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n LUMINANCE_TYPE lumaSimilarity = max(1. - lumaDiff / lumaPhi, 0.);\n float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n LUMINANCE_TYPE w = lumaSimilarity * depthSimilarity * normalSimilarity;\n\n denoised += w * neighborColor;\n totalWeight += w;\n}\n\nvoid main() {\n float depth = getDepth(vUv.xy);\t\n vec3 viewNormal = getViewNormal(vUv);\t\n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n\n LUMINANCE_TYPE totalWeight = LUMINANCE_TYPE(1.);\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n #if SCREEN_SPACE_RADIUS == 1\n vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);\n vec2 sampleUv = vUv + offset;\n #else\n vec3 offsetViewPos = viewPos + vec3(sampleDir.xy, 0.) * sampleDir.z * radius;\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(offsetViewPos, 1.0); \n vec2 sampleUv = (samplePointNDC.xy / samplePointNDC.w * 0.5 + 0.5);\n #endif\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n denoised /= totalWeight + 1.0 - step(0.0, totalWeight);\n gl_FragColor = vec4(denoised, 1.);\n}"},Hu={iterations:2,samples:16,rings:2,radiusExponent:1,radius:5,lumaPhi:10,depthPhi:2,normalPhi:4};class Vu{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._outputRenderTargetIndex].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n){this.needsUpdate=!0,this.parameters=Object.assign({},Hu),this._width=0,this._height=0,this._normalVectorSourceType=Tu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=Eu.NORMAL_VECTOR_ALPHA,this._rgInputTexture=!0,this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._outputRenderTargetIndex=0,this._renderPass=new oc,this._width=e,this._height=t,this._normalVectorSourceType=(null==n?void 0:n.normalVectorSourceType)||Tu.FLOAT_BUFFER_NORMAL,this._depthValueSourceType=(null==n?void 0:n.depthValueSourceType)||Eu.NORMAL_VECTOR_ALPHA,this._rgInputTexture=(null==n?void 0:n.rgInputTexture)||!0,this._inputTexture=(null==n?void 0:n.inputTexture)||null,this.depthTexture=(null==n?void 0:n.depthTexture)||null,this.normalTexture=(null==n?void 0:n.normalTexture)||null,(null==n?void 0:n.poissonDenoisePassParameters)&&(this.parameters=n.poissonDenoisePassParameters),n&&this.updateTextures(n)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new $l,n=new Uint8Array(e*e*4);for(let i=0;ie.dispose()))}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach((n=>n.setSize(e,t))),this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const i=this._getRenderTargets();for(let t=0;t.001,r=e===Gu.HARD&&t>.001&&t<.999;return{fadeInPoissonShadow:i,fadeInHardShadow:r,onlyHardShadow:e===Gu.HARD&&!r,progressiveDenoise:!i&&!r&&n>1&&n<=this.parameters.progressiveDenoiseIterations+1}}render(e,t,n,i,r=Gu.FULL,a=Gu.FULL,s=0,o=0){if(!this._setRenderState())return;const l=this._getRenderConditions(a,s,o);let c=!1;!l.onlyHardShadow&&r===Gu.FULL&&this._evaluateIfUpdateIsNeeded(n)&&(this._renderShadowAndAo(e,t,n,i),c=!0);let h=l.onlyHardShadow?i:this.denoiseRenderTargetTexture;l.fadeInPoissonShadow&&(h=this._renderDynamicShadow(e,this.shadowAndAoRenderTargets.passRenderTarget.texture,i,s),c=!0),c?h=this._renderDenoise(e,n,l.fadeInPoissonShadow,!1):l.progressiveDenoise&&(h=this._renderDenoise(e,n,!1,!0)),l.fadeInHardShadow&&(h=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,i,s)),this._renderToTarget(e,h,l.onlyHardShadow)}_setRenderState(){return this.shadowAndAoRenderTargets.shadowEnabled=this.parameters.shadowIntensity>.01,!(!this.parameters.enabled||null===this.parameters.ao.algorithm&&!this.shadowAndAoRenderTargets.shadowEnabled||(this.needsUpdate&&(this._aoPass&&(this._aoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,i){var r;const a=null!==this.parameters.ao.algorithm&&this.parameters.aoIntensity>.01;this.gBufferRenderTarget.render(e,t,n),a||null===(r=this._aoPass)||void 0===r||r.clear(e,this.shadowAndAoRenderTargets.passRenderTarget),this.shadowAndAoRenderTargets.render(e,n,i),a&&this._renderAo(e,t,n)}_renderAo(e,t,n){const i=this.gBufferRenderTarget.depthBufferTexture,r=this.gBufferRenderTarget.gBufferTexture,a=this.shadowAndAoRenderTargets.passRenderTarget,s=e.autoClear;e.autoClear=!1;const o=this.aoRenderPass;o.depthTexture=i,o.normalTexture=r,o.render(e,n,t,a),e.autoClear=s}_renderDynamicShadow(e,t,n,i=1){const r=i<.999;return r&&(this._copyMaterial.update({texture:t,blending:0,colorTransform:Ol,multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),i>.001&&(this._blendMaterial.update({texture:n,blending:r?5:0,colorTransform:(new Rt).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,r?i:1),multiplyChannels:0}),this._renderPass.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n,i){const r=this.denoisePass;return r.inputTexture=n?this.fadeRenderTarget.texture:i?r.texture:this.shadowAndAoRenderTargets.passRenderTarget.texture,r.render(e,t),r.texture}_renderToTarget(e,t,n){const i=n?this.parameters.shadowIntensity:this.parameters.aoIntensity,r=n?0:this.parameters.shadowIntensity;this._renderPass.renderScreenSpace(e,this._copyMaterial.update({texture:t,blending:5,colorTransform:Wl(i,r,0,1),multiplyChannels:1}),e.getRenderTarget())}}ju.shadowTransform=(new Rt).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class Xu{get passRenderTarget(){var e;return this._passRenderTarget=null!==(e=this._passRenderTarget)&&void 0!==e?e:new qe(this._width,this._height,{samples:this._targetSamples,format:z,magFilter:A,minFilter:A}),this._passRenderTarget}get passRenderMaterial(){var e;return this._passRenderMaterial=null!==(e=this._passRenderMaterial)&&void 0!==e?e:new Yu({normalTexture:this._depthAndNormalTextures.gBufferTexture,depthTexture:this._depthAndNormalTextures.depthBufferTexture,noiseTexture:this.noiseTexture,sampleKernel:this.sampleKernel,floatGBufferRgbNormalAlphaDepth:this._depthAndNormalTextures.isFloatGBufferWithRgbNormalAlphaDepth}),this._passRenderMaterial}get noiseTexture(){var e;return this._noiseTexture=null!==(e=this._noiseTexture)&&void 0!==e?e:sc(5),this._noiseTexture}get sampleKernel(){return this._sampleKernel.length||(this._sampleKernel=(e=>{const t=[];for(let n=0;n\n \n float getDepth(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if DEPTH_BUFFER_ANTIALIAS == 1\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float d0 = texelFetch(tNormal, p, 0).w;\n vec2 depth = vec2(d0, 1.0);\n float d1 = texelFetch(tNormal, p + ivec2(1, 0), 0).w;\n depth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n float d2 = texelFetch(tNormal, p - ivec2(1, 0), 0).w;\n depth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n float d3 = texelFetch(tNormal, p + ivec2(0, 1), 0).w;\n depth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n float d4 = texelFetch(tNormal, p - ivec2(0, 1), 0).w;\n depth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n return depth.x / depth.y;\n #else\n return texture2D(tNormal, screenPosition).w;\n #endif\n #else \n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n \n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n \n vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraInverseProjectionMatrix * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n vec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n #if NORMAL_VECTOR_ANTIALIAS == 1\n vec2 uv = screenPosition;\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float c0 = texelFetch(tNormal, p, 0).a;\n float l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n float l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n float r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n float r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n float b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n float b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n float t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n float t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n #elif NORMAL_VECTOR_ANTIALIAS == 2\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n vec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n return normalize(normalVector);\n #else\n return texture2D(tNormal, screenPosition).xyz;\n #endif\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n\n vec3 getViewNormal(const in vec2 screenPosition) {\n #if FLOAT_GBUFFER_RGB_NORMAL_ALPHA_DEPTH == 1\n return texture2D(tNormal, screenPosition).xyz;\n #else\n return unpackRGBToNormal(texture2D(tNormal, screenPosition).xyz);\n #endif\n }\n \n void main() {\n \n float depth = getDepth(vUv);\n float viewZ = getViewZ(depth);\n \n vec3 viewPosition = getViewPosition(vUv, depth);\n vec3 viewNormal = getAntiAliasedViewNormal(vUv);\n vec3 worldPosition = (cameraWorldMatrix * vec4(viewPosition, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPosition, worldPosition - sceneBoxMax)));\n \n vec2 noiseScale = resolution.xy / vec2(textureSize(tNoise, 0));\n vec3 random = texture2D(tNoise, vUv * noiseScale).xyz * 2.0 - 1.0;\n \n // compute matrix used to reorient a kernel vector\n vec3 tangent = normalize(random - viewNormal * dot(random, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n \n float shOcclusion = texture2D(tShadow, vUv).r;\n float shSamples = 0.0;\n if (shIntensity >= 0.01 && length(viewNormal) > 0.01) {\n for (int i = 0; i < KERNEL_SIZE; i ++) {\n vec3 shSampleVector = kernelMatrix * sampleKernel[i]; // reorient sample vector in view space\n vec3 shSamplePoint = viewPosition + shSampleVector * shKernelRadius; // calculate sample point\n vec4 shSamplePointNDC = cameraProjectionMatrix * vec4(shSamplePoint, 1.0); // project point and calculate NDC\n shSamplePointNDC /= shSamplePointNDC.w;\n vec2 shSamplePointUv = shSamplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n vec3 shSampleNormal = getViewNormal(shSamplePointUv);\n float shDeltaZ = getViewZ(getDepth(shSamplePointUv)) - shSamplePoint.z;\n float w = step(abs(shDeltaZ), shKernelRadius) * max(0.0, dot(shSampleNormal, viewNormal));\n shSamples += w;\n shOcclusion += texture2D(tShadow, shSamplePointUv).r * w;\n }\n }\n \n shOcclusion = clamp(shOcclusion / (shSamples + 1.0), 0.0, 1.0);\n gl_FragColor = vec4(1., shOcclusion, 0.0, 1.0);\n }"};class qu{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n){var i;this._width=e,this._height=t,this.parameters=Object.assign({enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4},n),this._copyMaterial=new Xl({}),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new Zu({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new lc(Yl,n),this._renderPass=null!==(i=null==n?void 0:n.renderPass)&&void 0!==i?i:new oc}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale,i={};if(e){const e=new sr(t,n);e.format=F,e.type=N,i.minFilter=M,i.magFilter=M,i.depthTexture=e}else i.samples=1;return new qe(t,n,Object.assign({format:O},i))}dispose(){var e,t,n;null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,i,r,a;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._intensityRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(r=this._blurRenderTarget)||void 0===r||r.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(a=this._reflectionIntensityMaterial)||void 0===a||a.update({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const i=this.parameters.intensity*t,r=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new Rt).set(r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,i),multiplyChannels:0,uvTransform:Gl}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}render(e,t,n,i=1){if(!(this.parameters.enabled&&n instanceof di))return;const r=this._createGroundReflectionCamera(n);this._renderGroundReflection(e,t,r,this.reflectionRenderTarget),this._renderGroundReflectionIntensity(e,r,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,n,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,i),this._renderPass.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,i){const r=e.getRenderTarget();i&&e.setRenderTarget(i),e.render(t,n),i&&e.setRenderTarget(r)}_renderGroundReflectionIntensity(e,t,n){const i=e.getRenderTarget();e.setRenderTarget(n),this._renderPass.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(i)}blurReflection(e,t,n){const i=new Qe(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),r=this.parameters.blurHorizontal/this._width,a=this.parameters.blurVertical/this._height*Math.abs(i.dot(new Qe(0,0,1)));this._blurPass.render(e,n,[4*r,4*a],[4*r*(1+this.parameters.blurAscent),4*a*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class Zu extends ci{constructor(e){super({defines:Object.assign({},Zu.shader.defines),uniforms:li.clone(Zu.shader.uniforms),vertexShader:Zu.shader.vertexShader,fragmentShader:Zu.shader.fragmentShader,blending:0}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}Zu.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new Me},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new Rt},cameraInverseProjectionMatrix:{value:new Rt},inverseViewMatrix:{value:new Rt},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include \n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec4 fragColor = texture2D(tDiffuse, uv).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha;\n gl_FragColor = fragColor * step(depth, 0.9999);\n }"};class Ku{constructor(e){this.grayMaterial=new So({color:12632256,side:2,envMapIntensity:.4}),this._renderPass=new oc,this._sceneRenderer=e,this._environmentMapDecodeMaterial=new _c(!0,!1),this._environmentMapDecodeMaterial.blending=0,this._environmentMapDecodeMaterial.depthTest=!1}get _gBufferRenderTarget(){return this._sceneRenderer.gBufferRenderTarget}get _screenSpaceShadow(){return this._sceneRenderer.screenSpaceShadow}get _shadowAndAoPass(){return this._sceneRenderer.shadowAndAoPass}get _groundReflectionPass(){return this._sceneRenderer.groundReflectionPass}get _bakedGroundContactShadow(){return this._sceneRenderer.bakedGroundContactShadow}dispose(){var e,t;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.grayMaterial.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new Xl,this._copyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new ql({depthTexture:this._gBufferRenderTarget.textureWithDepthValue,depthFilter:this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?new Xe(0,0,0,1):new Xe(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}render(e,t,n,i,r,a,s){e(i,r,a),"color"!==s?("grayscale"===s?this._sceneRenderer.renderCacheManager.render("debug",r,(()=>{this._renderPass.renderWithOverrideMaterial(i,r,a,this.grayMaterial,null,0,1)})):t(i,r,a),n(i,r,a),this._renderDebugPass(i,r,a,s)):i.render(r,a)}_renderDebugPass(e,t,n,i){var r,a,s,o,l,c;switch(i){default:break;case"lineardepth":this._renderPass.renderScreenSpace(e,this._getDepthRenderMaterial(n),null);break;case"g-normal":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(r=this._gBufferRenderTarget)||void 0===r?void 0:r.gBufferTexture,blending:0,colorTransform:(new Rt).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new Xe(.5,.5,.5,1),multiplyChannels:0,uvTransform:Vl}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(a=this._gBufferRenderTarget)||void 0===a?void 0:a.gBufferTexture,blending:0,colorTransform:Ul,colorBase:Hl,multiplyChannels:0,uvTransform:Vl}),null);break;case"g-depth":this._gBufferRenderTarget.isFloatGBufferWithRgbNormalAlphaDepth?this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(s=this._gBufferRenderTarget)||void 0===s?void 0:s.gBufferTexture,blending:0,colorTransform:Fl,colorBase:Hl,multiplyChannels:0,uvTransform:Vl}),null):this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:null===(o=this._gBufferRenderTarget)||void 0===o?void 0:o.depthBufferTexture,blending:0,colorTransform:Bl,colorBase:Hl,multiplyChannels:0,uvTransform:Vl}),null);break;case"ssao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:0,colorTransform:zl,colorBase:kl,multiplyChannels:0,uvTransform:Vl}),null);break;case"ssaodenoise":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:zl,colorBase:kl,multiplyChannels:0,uvTransform:Vl}),null);break;case"shadowmap":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._screenSpaceShadow.shadowTexture,blending:0,colorTransform:zl,colorBase:kl,multiplyChannels:0,uvTransform:Vl}),null);break;case"shadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.shadowAndAoRenderTargets.passRenderTarget.texture,blending:0,colorTransform:ju.shadowTransform,colorBase:kl,multiplyChannels:0,uvTransform:Vl}),null);break;case"shadowblur":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:ju.shadowTransform,colorBase:kl,multiplyChannels:0,uvTransform:Vl}),null);break;case"shadowfadein":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.fadeRenderTarget.texture,blending:0,colorTransform:ju.shadowTransform,colorBase:kl,multiplyChannels:0,uvTransform:Vl}),null);break;case"shadowandao":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:Wl(this._shadowAndAoPass.parameters.aoIntensity,this._shadowAndAoPass.parameters.shadowIntensity,0,1),colorBase:kl,multiplyChannels:1,uvTransform:Vl}),null);break;case"groundreflection":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._groundReflectionPass.reflectionRenderTarget.texture,blending:0,colorTransform:Ol,colorBase:kl,multiplyChannels:0,uvTransform:Gl}),null);break;case"bakedgroundshadow":this._renderPass.renderScreenSpace(e,this.getCopyMaterial({texture:this._bakedGroundContactShadow.renderTarget.texture,blending:0,colorTransform:Ol,colorBase:kl,multiplyChannels:0,uvTransform:Vl}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(t.environment),this._renderPass.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(l=t.userData)||void 0===l?void 0:l.environmentDefinition){const n=this._sceneRenderer.width/this._sceneRenderer.height,i=new Ui(-1,1,1/n,-1/n,-1,1),r=null===(c=t.userData)||void 0===c?void 0:c.environmentDefinition.createDebugScene(e,t,this._sceneRenderer.screenSpaceShadow.parameters.maximumNumberOfLightSources);r.background=new vn(16777215),e.render(r,i)}}}}var Ju;!function(e){e[e.HIGHEST=0]="HIGHEST",e[e.HIGH=1]="HIGH",e[e.MEDIUM=2]="MEDIUM",e[e.LOW=3]="LOW"}(Ju||(Ju={}));class Qu{constructor(e,t,n){this.debugOutput="off",this._prevDebugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.movingCamera=!1,this.groundLevel=0,this.uiInteractionMode=!1,this._noUpdateNeededCount=0,this._noOStaticFrames=0,this._cameraUpdate=new ac,this.width=0,this.height=0,this._maxSamples=1,this._cameraChanged=!0,this.boundingVolume=new ic,this._boundingVolumeSet=!1,this.renderCacheManager=new iu,this._renderPass=new oc,this.selectedObjects=[],this.groundGroup=new Qa,this._qualityLevel=Ju.HIGHEST,this._qualityMap=new Map,this.width=t,this.height=n,this._maxSamples=rc(e),this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new ru((e=>e===this.groundGroup))),this.renderCacheManager.registerCache("debug",new ru),this.renderCacheManager.registerCache("floorDepthWrite",new au((e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor}))),this.gBufferRenderTarget=new lu(this.renderCacheManager,{shared:!0,capabilities:e.capabilities,width:this.width,height:this.height,samples:1,renderPass:this._renderPass}),this.shadowAndAoPass=new ju(this.width,this.height,1,{gBufferRenderTarget:this.gBufferRenderTarget}),this.screenSpaceShadow=new bu(this.renderCacheManager,new Me(this.width,this.height),{samples:this._maxSamples,alwaysUpdate:!1}),this.groundReflectionPass=new qu(this.width,this.height,{renderPass:this._renderPass}),this._shadowAndAoGroundPlane=new hu(null),this.bakedGroundContactShadow=new du(this.renderer,this.groundGroup,{renderPass:this._renderPass,renderCacheManager:this.renderCacheManager,sharedShadowGroundPlane:this._shadowAndAoGroundPlane}),this.groundGroup.rotateX(-Math.PI/2),this.outlineRenderer=new gu(null,this.width,this.height,{gBufferRenderTarget:this.gBufferRenderTarget}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderTarget.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadow.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadow.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:Gu.OFF},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",(()=>{console.log("webglcontextlost")})),e.domElement.addEventListener("webglcontextrestored",(()=>{console.log("webglcontextrestored"),this._forceEnvironmentMapUpdate(this.renderer)}))}dispose(){var e,t;null===(e=this._debugPass)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),this.gBufferRenderTarget.dispose(),this.screenSpaceShadow.dispose(),this.shadowAndAoPass.dispose(),this.outlineRenderer.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this.gBufferRenderTarget.setSize(e,t),this.screenSpaceShadow.setSize(e,t),this.shadowAndAoPass.setSize(e,t),this.outlineRenderer.setSize(e,t),this.groundReflectionPass.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}applyCurrentParameters(){this._qualityMap.has(this._qualityLevel)&&(this.updateParameters(this._qualityMap.get(this._qualityLevel)),this.bakedGroundContactShadow.applyParameters()),this.uiInteractionMode&&this.updateParameters({groundReflectionParameters:{enabled:!1}})}clearCache(){this.renderCacheManager.clearCache()}forceShadowUpdates(e){this.clearCache(),this.gBufferRenderTarget.needsUpdate=!0,this.screenSpaceShadow.forceShadowUpdate(),this.shadowAndAoPass.needsUpdate=!0,e&&(this.bakedGroundContactShadow.needsUpdate=!0)}updateParameters(e){void 0!==e.shAndAoPassParameters&&this.shadowAndAoPass.updateParameters(e.shAndAoPassParameters),void 0!==e.bakedGroundContactShadowParameters&&this.bakedGroundContactShadow.updateParameters(e.bakedGroundContactShadowParameters),void 0!==e.screenSpaceShadowMapParameters&&this.screenSpaceShadow.updateParameters(e.screenSpaceShadowMapParameters),void 0!==e.groundReflectionParameters&&this.groundReflectionPass.updateParameters(e.groundReflectionParameters),void 0!==e.outlineParameters&&this.outlineRenderer.updateParameters(e.outlineParameters),void 0!==e.effectSuspendFrames&&(this.parameters.effectSuspendFrames=e.effectSuspendFrames),void 0!==e.effectFadeInFrames&&(this.parameters.effectFadeInFrames=e.effectFadeInFrames),void 0!==e.suspendGroundReflection&&(this.parameters.suspendGroundReflection=e.suspendGroundReflection),void 0!==e.shadowOnCameraChange&&(this.parameters.shadowOnCameraChange=e.shadowOnCameraChange)}addRectAreaLight(e,t){this.environmentLights=!1,this.screenSpaceShadow.addRectAreaLight(e,t),this.shadowAndAoPass.needsUpdate=!0}updateRectAreaLights(e,t){e.length>0&&(this.environmentLights=!1),this.screenSpaceShadow.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadow.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache(),this._boundingVolumeSet=!0,this.gBufferRenderTarget.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(e);const n=this.boundingVolume.size,i=(n.x+n.y+n.z)/3,r=Math.min(n.x,n.y,n.z),a=Math.max(n.x,n.y,n.z),s=r<.5?r/.5:n.z>5?n.z/5:1;this.bakedGroundContactShadow.setScale(t?i:s,i),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,a)),this.screenSpaceShadow.updateBounds(this.boundingVolume,i),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?i:Math.min(1,2*a))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_setRenderState(e,t){var n;const i=this.debugOutput!==this._prevDebugOutput;this._prevDebugOutput=this.debugOutput,this.screenSpaceShadow.parameters.alwaysUpdate=this.shadowAndAoPass.parameters.alwaysUpdate,this._cameraChanged=this._cameraUpdate.changed(t),(n=this.gBufferRenderTarget).needsUpdate||(n.needsUpdate=this._cameraChanged||i)}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,i;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const r=e.userData;if(r&&((null===(i=t.userData)||void 0===i?void 0:i.environmentDefinition.needsUpdate)||!r.environmentTexture||r.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(r.environmentDefinition=n,r.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadow.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==r?void 0:r.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}_setGroundVisibility(e){this._shadowAndAoGroundPlane.setVisibility(e)}render(e,t){e.add(this.groundGroup),this._setRenderState(e,t),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.movingCamera?[]:this.selectedObjects),this.renderer.setRenderTarget(null),this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput?this._renderDebug(this.renderer,e,t):(this.renderPreRenderPasses(this.renderer,e,t),this._renderScene(this.renderer,e,t),this.renderPostProcessingEffects(this.renderer,e,t)),e.remove(this.groundGroup)}_renderDebug(e,t,n){var i;this._debugPass=null!==(i=this._debugPass)&&void 0!==i?i:new Ku(this),this._debugPass.render(((e,t,n)=>this.renderPreRenderPasses(e,t,n)),((e,t,n)=>this._renderScene(e,t,n)),((e,t,n)=>this.renderPostProcessingEffects(e,t,n)),e,t,n,this.debugOutput)}renderPreRenderPasses(e,t,n){this._renderGroundContactShadow(t)}_renderScene(e,t,n){this.renderCacheManager.onBeforeRender("floorDepthWrite",t),this._setGroundVisibility(this.bakedGroundContactShadow.parameters.enabled),e.render(t,n),this._setGroundVisibility(!1),this.renderCacheManager.onAfterRender("floorDepthWrite")}renderPostProcessingEffects(e,t,n){this.renderShadowAndAo(e,t,n),this._renderOutline()}_renderGroundContactShadow(e){this.bakedGroundContactShadow.needsUpdate&&this.bakedGroundContactShadow.updateBounds(this.boundingVolume,this.groundLevel),this.bakedGroundContactShadow.render(e)}renderShadowAndAo(e,t,n){const i=this._evaluateIfShadowAndAoUpdateIsNeeded(n);if(i.needsUpdate||i.shadowOnCameraChange!==Gu.OFF){if(!this.parameters.suspendGroundReflection||i.needsUpdate){const r=this.parameters.suspendGroundReflection?i.intensityScale:1;this._renderGroundReflection(e,t,n,r)}this.gBufferRenderTarget.needsUpdate=i.needsUpdate||i.shadowOnCameraChange===Gu.POISSON,this._setGroundVisibility(this._boundingVolumeSet&&this.shadowAndAoPass.parameters.aoOnGround),this.gBufferRenderTarget.render(e,t,n),this._setGroundVisibility(!1),this.shadowAndAoPass.parameters.shadowIntensity>0&&(this._setGroundVisibility(this.shadowAndAoPass.parameters.shadowOnGround),this.screenSpaceShadow.renderShadowMap(e,t,n),this._setGroundVisibility(!1)),this.shadowAndAoPass.render(e,t,n,this.screenSpaceShadow.shadowTexture,i.needsUpdate?Gu.FULL:i.shadowOnCameraChange,i.shadowOnCameraChange,1-i.intensityScale,this._noOStaticFrames)}}_evaluateIfShadowAndAoUpdateIsNeeded(e){const t=this.shadowAndAoPass.parameters.alwaysUpdate||this.screenSpaceShadow.needsUpdate||this.screenSpaceShadow.shadowTypeNeedsUpdate;let n=(this.shadowAndAoPass.parameters.enabled||this.groundReflectionPass.parameters.enabled)&&this._cameraChanged,i=1;return n&&(this._noUpdateNeededCount=0,this._noOStaticFrames=0),t||(this._noUpdateNeededCount++,n=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,i=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),t||1!==i||this._noOStaticFrames++,n=t||n,{needsUpdate:n,shadowOnCameraChange:!n||i<.99?this.parameters.shadowOnCameraChange:Gu.OFF,intensityScale:i}}_renderGroundReflection(e,t,n,i=1){this.groundReflectionPass.parameters.enabled&&this.renderCacheManager.render("inivisibleGround",t,(()=>{this.groundReflectionPass.render(e,t,n,i)}))}_renderOutline(){if(this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass){const e=this.renderer.getClearColor(new vn),t=this.renderer.getClearAlpha();"outline"===this.debugOutput&&(this.renderer.setClearColor(0,255),this.renderer.clear(!0,!1,!1)),this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.render(this.renderer,null,null,0,!1),"outline"===this.debugOutput&&this.renderer.setClearColor(e,t)}}}class $u extends $t{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 Me(.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 ep=new Qe,tp=new Rt,np=new Rt,ip=new Qe,rp=new Qe;class ap extends Qa{constructor(e,t,n){super(),this.arrowNeedsUpdate=!0,this.labelTextClientWidth=0,this.startPosition=e.clone(),this.endPosition=t.clone(),this.parameters=Object.assign({shaftPixelWidth:10,shaftPixelOffset:3,arrowPixelWidth:30,arrowPixelHeight:50,color:0,labelClass:"label",deviceRatio:1,autoLabelTextUpdate:!0,autoLabelRotationUpdate:!0},n),this.startShaftMaterial=new sp,this.startShaft=new ni(new Ti(2,1).translate(0,.5,0),this.startShaftMaterial),this.startShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!0,e,n,r)},this.add(this.startShaft),this.endShaftMaterial=new sp,this.endShaft=new ni(new Ti(2,1).translate(0,.5,0),this.endShaftMaterial),this.endShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!1,e,n,r)},this.add(this.endShaft),this.startArrowMaterial=new op,this.startArrow=new ni(new Ti(2,1).translate(0,.5,0),this.startArrowMaterial),this.startArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!0,e,n,r)},this.add(this.startArrow),this.endArrowMaterial=new op,this.endArrow=new ni(new Ti(2,1).translate(0,.5,0),this.endArrowMaterial),this.endArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!1,e,n,r)},this.add(this.endArrow),this.arrowLabel=this.createArrowLabel("0.000",this.parameters),this.add(this.arrowLabel),this.updateArrow()}createArrowLabel(e,t){var n,i,r,a,s,o;const l=document.createElement("div"),c=document.createElement("div");l.appendChild(c),c.className=null!==(n=t.labelClass)&&void 0!==n?n:"",c.textContent=e,c.style.backgroundColor="transparent",c.style.color=new vn(null!==(i=t.color)&&void 0!==i?i:0).getStyle();const h=new $u(l);return h.position.set(0,0,0),h.center.set(null!==(a=null===(r=t.origin)||void 0===r?void 0:r.x)&&void 0!==a?a:.5,null!==(o=null===(s=t.origin)||void 0===s?void 0:s.y)&&void 0!==o?o:.5),h.layers.set(0),h}setPosition(e,t,n=0,i=0){const r=t.clone().sub(e).normalize();this.startPosition.copy(e.clone().add(r.clone().multiplyScalar(n))),this.endPosition.copy(t.clone().add(r.clone().multiplyScalar(-i))),this.arrowNeedsUpdate=!0}setAngle(e){const t=`${e.toFixed(0)}deg`;this.arrowLabel.element.children[0].style.rotate=t}setLabel(e){const t=this.arrowLabel.element.children[0];t.textContent=e,this.labelTextClientWidth=t.clientWidth*this.parameters.deviceRatio}updateArrow(){const e=this.startPosition.clone().applyMatrix4(this.matrixWorld),t=this.endPosition.clone().applyMatrix4(this.matrixWorld),n=t.clone().sub(e),i=n.length();n.multiplyScalar(1/i);const r=new Qe(0,1,0).cross(n),a=Math.acos(new Qe(0,1,0).dot(n));this.setModelMatrix(this.startShaft,e,i,r,a),this.setModelMatrix(this.endShaft,t,i,r,a),this.setModelMatrix(this.startArrow,e,1,r,a),this.setModelMatrix(this.endArrow,t,1,r,a+Math.PI)}updateArrowLabel(e,t){var n,i;const r=this.startPosition.distanceTo(this.endPosition).toFixed(3),a=this.startPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),s=this.endPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),o=s.clone().add(a).multiplyScalar(.5).applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);this.arrowLabel.position.copy(o);const l=e.getRenderTarget(),c=null!==(n=null==l?void 0:l.width)&&void 0!==n?n:e.domElement.clientWidth,h=null!==(i=null==l?void 0:l.height)&&void 0!==i?i:e.domElement.clientHeight,d=s.clone().sub(a),u=180*Math.atan2(-d.y,d.x*c/h)/Math.PI;this.parameters.autoLabelRotationUpdate&&this.setAngle(u),this.parameters.autoLabelTextUpdate&&this.setLabel(r)}setModelMatrix(e,t,n,i,r){e.scale.set(1,1,1),e.rotation.set(0,0,0),e.position.set(0,0,0),e.applyMatrix4((new Rt).makeScale(1,.5*n,1)),e.applyMatrix4((new Rt).makeRotationAxis(i,r)),e.applyMatrix4((new Rt).makeTranslation(t.x,t.y,t.z))}updateShaftMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof sp){const s=t.getRenderTarget(),o=new Me;t.getSize(o);const l=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:o.x,c=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:o.y,h=this.startPosition.clone().applyMatrix4(this.matrixWorld),d=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:l,height:c,camera:n,start:e?h:d,end:e?d:h,shaftPixelWidth:this.parameters.shaftPixelWidth,shaftPixelOffset:this.parameters.shaftPixelOffset,arrowPixelSize:new Me(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),labelPixelWidth:this.labelTextClientWidth,color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}updateArrowMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof op){const s=t.getRenderTarget(),o=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:t.domElement.clientWidth,l=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:t.domElement.clientHeight,c=this.startPosition.clone().applyMatrix4(this.matrixWorld),h=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:o,height:l,camera:n,start:e?c:h,end:e?h:c,arrowPixelSize:new Me(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}}class sp extends ci{constructor(e){super({defines:Object.assign({},sp.shader.defines),uniforms:li.clone(sp.shader.uniforms),vertexShader:sp.shader.vertexShader,fragmentShader:sp.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.shaftPixelWidth)&&(this.uniforms.shaftPixelWidth.value=e.shaftPixelWidth),void 0!==(null==e?void 0:e.shaftPixelOffset)&&(this.uniforms.shaftPixelOffset.value=e.shaftPixelOffset),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.labelPixelWidth)&&(this.uniforms.labelPixelWidth.value=e.labelPixelWidth),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new vn(e.color)),this}}sp.shader={uniforms:{resolution:{value:new Me},start:{value:new Qe},end:{value:new Qe},shaftPixelWidth:{value:10},shaftPixelOffset:{value:10},arrowPixelSize:{value:new Me},labelPixelWidth:{value:0},color:{value:new vn}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform float shaftPixelWidth;\nuniform float shaftPixelOffset;\nuniform vec2 arrowPixelSize;\nuniform float labelPixelWidth;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n vec4 shaftEnd = vec4(clipEnd.xy / clipEnd.w * clipStart.w, clipStart.zw);\n shaftEnd.xy -= clipDir * (labelPixelWidth * 0.5 + shaftPixelOffset) * pixelToNdcScale(gl_Position);\n gl_Position.xy = mix(clipStart.xy / clipStart.w, shaftEnd.xy / shaftEnd.w, position.y * 0.5) * gl_Position.w;\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * shaftPixelWidth * 0.5 * pixelToNdcScale(gl_Position);\n\n vec4 clipCenter = clipStart;\n float d = arrowPixelSize.y * (1.0 + RADIUS_RATIO) - length(arrowPixelSize * vec2(0.5, RADIUS_RATIO));\n clipCenter.xy += clipDir * (d + shaftPixelOffset + shaftPixelWidth * 0.5) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n arrowDir = clipDir;\n}",fragmentShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform float shaftPixelWidth;\nuniform vec3 color;\n\nvoid main() {\n if (dot(arrowDir, posPixel - centerPixel) < 0.0 && length(posPixel - centerPixel) > shaftPixelWidth * 0.5)\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};class op extends ci{constructor(e){super({defines:Object.assign({},op.shader.defines),uniforms:li.clone(op.shader.uniforms),vertexShader:op.shader.vertexShader,fragmentShader:op.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new vn(e.color)),this}}op.shader={uniforms:{resolution:{value:new Me},start:{value:new Qe},end:{value:new Qe},arrowPixelSize:{value:new Me},color:{value:new vn}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform vec2 arrowPixelSize;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n gl_Position.xy += clipDir * position.y * arrowPixelSize.y * pixelToNdcScale(gl_Position);\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * arrowPixelSize.x * 0.5 * pixelToNdcScale(gl_Position);\n\n arrowUv = position.xy;\n\n vec4 clipCenter = clipStart;\n clipCenter.xy += clipDir * arrowPixelSize.y * (1.0 + RADIUS_RATIO) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n}",fragmentShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec2 arrowPixelSize;\nuniform vec3 color;\n\nvoid main() {\n if (abs(arrowUv.x) > abs(arrowUv.y))\n discard;\n if (length(posPixel - centerPixel) < length(arrowPixelSize * vec2(0.5, RADIUS_RATIO)))\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};const lp="front",cp="all_around";class hp extends Ac{constructor(e={}){super(),this._parameters={},this._parameters=e}generateScene(e,t){const n=new dp(Object.assign(Object.assign({},this._parameters),{lightIntensity:e*(this._parameters.lightIntensity||1),topLightIntensity:e*(this._parameters.topLightIntensity||1),sidLightIntensity:e*(this._parameters.sidLightIntensity||1)}));return n.rotation.y=t,n}}class dp extends as{constructor(e={}){var t;super(),this._type=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:cp,this._topLightIntensity=(null==e?void 0:e.topLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideLightIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideReflectorIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._ambientLightIntensity=(null==e?void 0:e.ambientLightIntensity)||.25,this._colorVariation=(null==e?void 0:e.colorVariation)||.5,this._lightGeometry=new ri,this._lightGeometry.deleteAttribute("uv"),this.generateScene(this)}generateScene(e){switch(this._type){default:case cp:this._createAllAroundSceneLight(e);break;case lp:this._createFrontSceneLight(e)}}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}_createAllAroundSceneLight(e){const t=new fl(16777215);t.intensity=this._ambientLightIntensity,this.add(t),this._createTopLight(e,6,1);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);t%2==0?this._createReflector(e,new Me(i,r),3,1,1):this._createSideLight(e,new Me(i,r),(t-1)/2,15,1.1,.33)}}_createFrontSceneLight(e){const t=new fl(16777215);t.intensity=this._ambientLightIntensity,this.add(t),this._createTopLight(e,5,.9);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);if(0===t){this._createReflector(e,new Me(i,r),3,.8,.4);for(let n=0;n<2;n++){const i=(t-.2+.4*n)*Math.PI*2/6,r=Math.sin(i),a=Math.cos(i);this._createSideLight(e,new Me(r,a),(t-1)/2,20,1.1,.75)}}else this._createReflector(e,new Me(i,r),3,.8,1)}}_createAreaLightMaterial(e,t,n){const i=new Sn;return i.color.set(e,null!=t?t:e,null!=n?n:e),i}_createTopLight(e,t,n){const i=new ni(this._lightGeometry,this._createAreaLightMaterial(t*this._topLightIntensity));i.position.set(0,20,0),i.scale.set(5*n,.1,5*n),e.add(i)}_createSideLight(e,t,n,i,r,a){for(let s=0;s<3;s++){const o=i*this._sideLightIntensity,l=new ni(this._lightGeometry,this._createAreaLightMaterial((s+n)%3==0?o:o*(1-this._colorVariation),(s+n)%3==1?o:o*(1-this._colorVariation),(s+n)%3==2?o:o*(1-this._colorVariation))),c=(1===s?-t.y:2===s?t.y:0)/Math.sqrt(2),h=0===s?0:1,d=(1===s?t.x:2===s?-t.x:0)/Math.sqrt(2);l.position.set(15*t.x+1.1*c*r,15*a+1.1*h*r,15*t.y+1.1*d*r),l.rotation.set(0,Math.atan2(t.x,t.y),0),l.scale.setScalar(r),e.add(l)}}_createReflector(e,t,n,i,r){const a=new ni(this._lightGeometry,this._createAreaLightMaterial(n*this._sideReflectorIntensity));a.position.set(15*t.x,5*r,15*t.y),a.rotation.set(0,Math.atan2(t.x,t.y),0),a.scale.set(10*i,12*i*r,10*i),e.add(a)}}const up={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:Gu.FULL},pp={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:Gu.POISSON},fp={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:Gu.HARD},mp={enabled:!0,aoOnGround:!0,shadowOnGround:!0,aoIntensity:1,shadowIntensity:1,ao:{algorithm:4,samples:16,radius:.5,distanceExponent:2,thickness:1,distanceFallOff:1,scale:1,bias:.01,screenSpaceRadius:!1}},gp={enableGroundBoundary:!1,directionalDependency:1,directionalExponent:1,groundBoundary:0,fadeOutDistance:.2,fadeOutBlur:5},vp=new Map([[Ju.HIGHEST,Object.assign(Object.assign({},up),{shAndAoPassParameters:mp,screenSpaceShadowMapParameters:gp,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[Ju.HIGH,Object.assign(Object.assign({},pp),{shAndAoPassParameters:mp,screenSpaceShadowMapParameters:gp,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[Ju.MEDIUM,Object.assign(Object.assign({},fp),{shAndAoPassParameters:mp,screenSpaceShadowMapParameters:gp,groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}})],[Ju.LOW,{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]]);class _p extends ni{constructor(e,t={}){const n=[e.isCubeTexture?"#define ENVMAP_TYPE_CUBE":""].join("\n")+"\n\n\t\t\t\tvarying vec3 vWorldPosition;\n\n\t\t\t\tuniform float radius;\n\t\t\t\tuniform float height;\n\t\t\t\tuniform float angle;\n\n\t\t\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\t\t\tuniform samplerCube map;\n\n\t\t\t\t#else\n\n\t\t\t\t\tuniform sampler2D map;\n\n\t\t\t\t#endif\n\n\t\t\t\t// From: https://www.shadertoy.com/view/4tsBD7\n\t\t\t\tfloat diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r ) \n\t\t\t\t{\n\n\t\t\t\t\tfloat d = dot ( rd, n );\n\n\t\t\t\t\tif( d > 0.0 ) { return 1e6; }\n\n\t\t\t\t\tvec3 o = ro - c;\n\t\t\t\t\tfloat t = - dot( n, o ) / d;\n\t\t\t\t\tvec3 q = o + rd * t;\n\n\t\t\t\t\treturn ( dot( q, q ) < r * r ) ? t : 1e6;\n\n\t\t\t\t}\n\n\t\t\t\t// From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm\n\t\t\t\tfloat sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra ) {\n\n\t\t\t\t\tvec3 oc = ro - ce;\n\t\t\t\t\tfloat b = dot( oc, rd );\n\t\t\t\t\tfloat c = dot( oc, oc ) - ra * ra;\n\t\t\t\t\tfloat h = b * b - c;\n\n\t\t\t\t\tif( h < 0.0 ) { return -1.0; }\n\n\t\t\t\t\th = sqrt( h );\n\n\t\t\t\t\treturn - b + h;\n\n\t\t\t\t}\n\n\t\t\t\tvec3 project() {\n\n\t\t\t\t\tvec3 p = normalize( vWorldPosition );\n\t\t\t\t\tvec3 camPos = cameraPosition;\n\t\t\t\t\tcamPos.y -= height;\n\n\t\t\t\t\tfloat intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius );\n\t\t\t\t\tif( intersection > 0.0 ) {\n\n\t\t\t\t\t\tvec3 h = vec3( 0.0, - height, 0.0 );\n\t\t\t\t\t\tfloat intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius );\n\t\t\t\t\t\tp = ( camPos + min( intersection, intersection2 ) * p ) / radius;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tp = vec3( 0.0, 1.0, 0.0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\treturn p;\n\n\t\t\t\t}\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 projectedWorldPosition = project();\n\n\t\t\t\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\t\t\t\tvec3 outcolor = textureCube( map, projectedWorldPosition ).rgb;\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tvec3 direction = normalize( projectedWorldPosition );\n\t\t\t\t\t\tvec2 uv = equirectUv( direction );\n\t\t\t\t\t\tvec3 outcolor = texture2D( map, uv ).rgb;\n\n\t\t\t\t\t#endif\n\n\t\t\t\t\tgl_FragColor = vec4( outcolor, 1.0 );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t\t",i={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}};super(new fo(1,16),new ci({uniforms:i,fragmentShader:n,vertexShader:"\n\t\t\tvarying vec3 vWorldPosition;\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) );\n\t\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t}\n\t\t\t",side:2}))}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}const xp=e.p+"916b55ac1b4c4c11f375.envmap";var yp=function(e,t,n,i){return new(n||(n=Promise))((function(r,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function o(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}l((i=i.apply(e,t||[])).next())}))};class Sp{constructor(){this.materials=[],this.materialId=""}updateMaterialUI(e,t){var n,i;this.materialFolder&&(e.removeFolder(this.materialFolder),this.materialProperties=void 0),this.materialFolder=e.addFolder("Materials"),this.materials=t,this.materialId=null!==(i=null===(n=t[0])||void 0===n?void 0:n.materialId)&&void 0!==i?i:"";const r=t.map((e=>{const t=e.materialId;return{materialId:e.materialId,name:t}})),a=Object.assign({},...r.map((e=>({[e.name]:e.materialId}))));this.materialFolder.add(this,"materialId",a).onChange((e=>this.updateMaterialPropertiesUI(e))),this.updateMaterialPropertiesUI(this.materialId)}updateMaterialPropertiesUI(e){var t,n,i,r,a,s,o,l,c,h;if(this.materialId=e,!this.materialFolder)return;this.materialProperties&&(this.materialFolder.removeFolder(this.materialProperties),this.materialProperties=void 0);const d=this.materials.find((t=>t.materialId===e));if(!d)return;const u=d.material;if(!u)return;const p={color:null!==(n=null===(t=u.color)||void 0===t?void 0:t.getHex())&&void 0!==n?n:16777215,specularColor:null!==(r=null===(i=u.color)||void 0===i?void 0:i.getHex())&&void 0!==r?r:16777215,emissive:null!==(s=null===(a=u.emissive)||void 0===a?void 0:a.getHex())&&void 0!==s?s:16777215,sheenColor:null!==(l=null===(o=u.emissive)||void 0===o?void 0:o.getHex())&&void 0!==l?l:16777215,attenuationColor:null!==(h=null===(c=u.emissive)||void 0===c?void 0:c.getHex())&&void 0!==h?h:16777215};let f="properties";d.material.userData&&(d.material.userData.diffuseMap&&(f+=d.material.userData.diffuseMapHasAlpha?" RGBA":" RGB"),d.material.userData.normalMap&&(f+=" XYZ"),d.material.userData.ormMap&&(f+=" ORM")),this.materialProperties=this.materialFolder.addFolder(f),this.materialProperties.addColor(p,"color").onChange(Sp.handleColorChange(u.color,!0)),this.materialProperties.add(u,"opacity",0,1).onChange((e=>{const t=e<1;t!==u.transparent&&(u.transparent=t,u.needsUpdate=!0)}));try{this.materialProperties.add(u,"metalness",0,1),this.materialProperties.add(u,"roughness",0,1),this.materialProperties.add(u,"transmission",0,1),this.materialProperties.add(u,"ior",1,2.333),this.materialProperties.add(u,"specularIntensity",0,1),this.materialProperties.addColor(p,"specularColor").onChange(Sp.handleColorChange(u.specularColor,!0)),this.materialProperties.add(u,"reflectivity",0,1),this.materialProperties.add(u,"clearcoat",0,1),this.materialProperties.add(u,"clearcoatRoughness",0,1),this.materialProperties.add(u,"sheen",0,1),this.materialProperties.add(u,"sheenRoughness",0,1),this.materialProperties.addColor(p,"sheenColor").onChange(Sp.handleColorChange(u.sheenColor,!0)),this.materialProperties.add(u,"emissiveIntensity",0,1),this.materialProperties.addColor(p,"emissive").onChange(Sp.handleColorChange(u.emissive,!0)),this.materialProperties.add(u,"attenuationDistance",0,50),this.materialProperties.addColor(p,"attenuationColor").onChange(Sp.handleColorChange(u.attenuationColor,!0)),this.materialProperties.add(u,"thickness",0,50)}catch(e){console.log(e)}}static handleColorChange(e,t=!1){return n=>{"string"==typeof n&&(n=n.replace("#","0x")),e.setHex(n),!0===t&&e.convertSRGBToLinear()}}}var wp=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i=a+1e3&&(o.update(1e3*s/(e-a),100),a=e,s=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};wp.Panel=function(e,t,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,c=3*s,h=2*s,d=3*s,u=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,c,h),g.fillRect(d,u,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,u,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,o,u),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(i)+"-"+a(r)+")",c,h),g.drawImage(m,d+s,u,p-s,f,d,u,p-s,f),g.fillRect(d+p-s,u,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-s,u,s,a((1-l/v)*f))}}};const bp=wp;function Mp(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),a=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),c=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var h=e.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}return"CSS_RGB"===n?"rgb("+i+","+r+","+a+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+a+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+a+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+a+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+",a:"+s+"}":"unknown format"}var Tp=Array.prototype.forEach,Ep=Array.prototype.slice,Ap={BREAK:{},extend:function(e){return this.each(Ep.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(Ep.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=Ep.call(arguments);return function(){for(var t=Ep.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(Tp&&e.forEach&&e.forEach===Tp)e.forEach(t,n);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r1?Ap.toArray(arguments):arguments[0];return Ap.each(Rp,(function(t){if(t.litmus(e))return Ap.each(t.conversions,(function(t,n){if(Cp=t.read(e),!1===Pp&&!1!==Cp)return Pp=Cp,Cp.conversionName=n,Cp.conversion=t,Ap.BREAK})),Ap.BREAK})),Pp},Dp=void 0,Ip={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,a],[s,n,a],[a,n,o],[a,s,n],[o,a,n],[n,a,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),a=r-i,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(s/=6)<0&&(s+=1),{h:360*s,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Dp=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var Qp=function(e){function t(e,n,i){Op(this,t);var r=zp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,Ap.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=Jp(r.__impliedStep),r}return Bp(t,e),Up(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=Jp(e),this}}]),t}(Gp),$p=function(e){function t(e,n,i){Op(this,t);var r=zp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var a=r,s=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=s-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),s=e.clientY}function c(){Yp.unbind(window,"mousemove",l),Yp.unbind(window,"mouseup",c),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),Yp.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Ap.isNaN(e)||a.setValue(e)})),Yp.bind(r.__input,"blur",(function(){o()})),Yp.bind(r.__input,"mousedown",(function(e){Yp.bind(window,"mousemove",l),Yp.bind(window,"mouseup",c),s=e.clientY})),Yp.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Bp(t,e),Up(t,[{key:"updateDisplay",value:function(){var e,n,i;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,i=Math.pow(10,n),Math.round(e*i)/i),Fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Qp);function ef(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var tf=function(e){function t(e,n,i,r,a){Op(this,t);var s=zp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(ef(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function c(){Yp.unbind(window,"mousemove",l),Yp.unbind(window,"mouseup",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function h(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(ef(t,n.left,n.right,o.__min,o.__max))}function d(){Yp.unbind(window,"touchmove",h),Yp.unbind(window,"touchend",d),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),Yp.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),Yp.bind(window,"mousemove",l),Yp.bind(window,"mouseup",c),l(e)})),Yp.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(Yp.bind(window,"touchmove",h),Yp.bind(window,"touchend",d),h(e))})),Yp.addClass(s.__background,"slider"),Yp.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return Bp(t,e),Up(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(Qp),nf=function(e){function t(e,n,i){Op(this,t);var r=zp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,Yp.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),Yp.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Bp(t,e),Up(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(Gp),rf=function(e){function t(e,n){Op(this,t);var i=zp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new kp(i.getValue()),i.__temp=new kp(0);var r=i;i.domElement=document.createElement("div"),Yp.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",Yp.bind(i.__input,"keydown",(function(e){13===e.keyCode&&d.call(this)})),Yp.bind(i.__input,"blur",d),Yp.bind(i.__selector,"mousedown",(function(){Yp.addClass(this,"drag").bind(window,"mouseup",(function(){Yp.removeClass(r.__selector,"drag")}))})),Yp.bind(i.__selector,"touchstart",(function(){Yp.addClass(this,"drag").bind(window,"touchend",(function(){Yp.removeClass(r.__selector,"drag")}))}));var a,s=document.createElement("div");function o(e){p(e),Yp.bind(window,"mousemove",p),Yp.bind(window,"touchmove",p),Yp.bind(window,"mouseup",c),Yp.bind(window,"touchend",c)}function l(e){f(e),Yp.bind(window,"mousemove",f),Yp.bind(window,"touchmove",f),Yp.bind(window,"mouseup",h),Yp.bind(window,"touchend",h)}function c(){Yp.unbind(window,"mousemove",p),Yp.unbind(window,"touchmove",p),Yp.unbind(window,"mouseup",c),Yp.unbind(window,"touchend",c),u()}function h(){Yp.unbind(window,"mousemove",f),Yp.unbind(window,"touchmove",f),Yp.unbind(window,"mouseup",h),Yp.unbind(window,"touchend",h),u()}function d(){var e=Lp(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,a=n.clientY,s=(i-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function f(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return Ap.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Ap.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Ap.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Ap.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Ap.extend(s.style,{width:"100%",height:"100%",background:"none"}),sf(s,"top","rgba(0,0,0,0)","#000"),Ap.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=i.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Ap.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),Yp.bind(i.__saturation_field,"mousedown",o),Yp.bind(i.__saturation_field,"touchstart",o),Yp.bind(i.__field_knob,"mousedown",o),Yp.bind(i.__field_knob,"touchstart",o),Yp.bind(i.__hue_field,"mousedown",l),Yp.bind(i.__hue_field,"touchstart",l),i.__saturation_field.appendChild(s),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return Bp(t,e),Up(t,[{key:"updateDisplay",value:function(){var e=Lp(this.getValue());if(!1!==e){var t=!1;Ap.each(kp.COMPONENTS,(function(n){if(!Ap.isUndefined(e[n])&&!Ap.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Ap.extend(this.__color.__state,e)}Ap.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;Ap.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,sf(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Ap.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(Gp),af=["-moz-","-o-","-webkit-","-ms-",""];function sf(e,t,n,i){e.style.background="",Ap.each(af,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}var of=function(e,t){var n=e[t];return Ap.isArray(arguments[2])||Ap.isObject(arguments[2])?new Zp(e,t,arguments[2]):Ap.isNumber(n)?Ap.isNumber(arguments[2])&&Ap.isNumber(arguments[3])?Ap.isNumber(arguments[4])?new tf(e,t,arguments[2],arguments[3],arguments[4]):new tf(e,t,arguments[2],arguments[3]):Ap.isNumber(arguments[4])?new $p(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new $p(e,t,{min:arguments[2],max:arguments[3]}):Ap.isString(n)?new Kp(e,t):Ap.isFunction(n)?new nf(e,t,""):Ap.isBoolean(n)?new qp(e,t):null},lf=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},cf=function(){function e(){Op(this,e),this.backgroundElement=document.createElement("div"),Ap.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Yp.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Ap.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Yp.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Up(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Ap.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Yp.unbind(e.domElement,"webkitTransitionEnd",t),Yp.unbind(e.domElement,"transitionend",t),Yp.unbind(e.domElement,"oTransitionEnd",t)};Yp.bind(this.domElement,"webkitTransitionEnd",t),Yp.bind(this.domElement,"transitionend",t),Yp.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Yp.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Yp.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}(function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var hf="Default",df=function(){try{return!!window.localStorage}catch(e){return!1}}(),uf=void 0,pf=!0,ff=void 0,mf=!1,gf=[],vf=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Yp.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=Ap.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=Ap.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),Ap.isUndefined(i.load)?i.load={preset:hf}:i.preset&&(i.load.preset=i.preset),Ap.isUndefined(i.parent)&&i.hideable&&gf.push(this),i.resizable=Ap.isUndefined(i.parent)&&i.resizable,i.autoPlace&&Ap.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=df&&"true"===localStorage.getItem(bf(0,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t1){var i=n.__li.nextElementSibling;return n.remove(),wf(e,n.object,n.property,{before:i,factoryArgs:[Ap.toArray(arguments)]})}if(Ap.isArray(t)||Ap.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),wf(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof tf){var i=new $p(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Ap.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),Yp.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof $p){var r=function(t){if(Ap.isNumber(n.__min)&&Ap.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=wf(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(i),r&&a.listen(),a}return t};n.min=Ap.compose(r,n.min),n.max=Ap.compose(r,n.max)}else n instanceof qp?(Yp.bind(t,"click",(function(){Yp.fakeEvent(n.__checkbox,"click")})),Yp.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof nf?(Yp.bind(t,"click",(function(){Yp.fakeEvent(n.__button,"click")})),Yp.bind(t,"mouseover",(function(){Yp.addClass(n.__button,"hover")})),Yp.bind(t,"mouseout",(function(){Yp.removeClass(n.__button,"hover")}))):n instanceof rf&&(Yp.addClass(t,"color"),n.updateDisplay=Ap.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Ap.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&yf(e.getRoot(),!0),t}),n.setValue)}(e,l,r),e.__controllers.push(r),r}function bf(e,t){return document.location.href+"."+t}function Mf(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function Tf(e,t){t.style.display=e.useLocalStorage?"block":"none"}function Ef(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function i(){Yp.removeClass(e.__closeButton,vf.CLASS_DRAG),Yp.unbind(window,"mousemove",n),Yp.unbind(window,"mouseup",i)}function r(r){return r.preventDefault(),t=r.clientX,Yp.addClass(e.__closeButton,vf.CLASS_DRAG),Yp.bind(window,"mousemove",n),Yp.bind(window,"mouseup",i),!1}e.__resize_handle=document.createElement("div"),Ap.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Yp.bind(e.__resize_handle,"mousedown",r),Yp.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Af(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Rf(e,t){var n={};return Ap.each(e.__rememberedObjects,(function(i,r){var a={},s=e.__rememberedObjectIndecesToControllers[r];Ap.each(s,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[r]=a})),n}function Cf(e){0!==e.length&&lf.call(window,(function(){Cf(e)})),Ap.each(e,(function(e){e.updateDisplay()}))}vf.toggleHide=function(){mf=!mf,Ap.each(gf,(function(e){e.domElement.style.display=mf?"none":""}))},vf.CLASS_AUTO_PLACE="a",vf.CLASS_AUTO_PLACE_CONTAINER="ac",vf.CLASS_MAIN="main",vf.CLASS_CONTROLLER_ROW="cr",vf.CLASS_TOO_TALL="taller-than-window",vf.CLASS_CLOSED="closed",vf.CLASS_CLOSE_BUTTON="close-button",vf.CLASS_CLOSE_TOP="close-top",vf.CLASS_CLOSE_BOTTOM="close-bottom",vf.CLASS_DRAG="drag",vf.DEFAULT_WIDTH=245,vf.TEXT_CLOSED="Close Controls",vf.TEXT_OPEN="Open Controls",vf._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||vf.toggleHide()},Yp.bind(window,"keydown",vf._keydownHandler,!1),Ap.extend(vf.prototype,{add:function(e,t){return wf(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return wf(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Ap.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&ff.removeChild(this.domElement);var e=this;Ap.each(this.__folders,(function(t){e.removeFolder(t)})),Yp.unbind(window,"keydown",vf._keydownHandler,!1),xf(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new vf(t);this.__folders[e]=n;var i=_f(this,n.domElement);return Yp.addClass(i,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],xf(e);var t=this;Ap.each(e.__folders,(function(t){e.removeFolder(t)})),Ap.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Yp.getOffset(e.__ul).top,n=0;Ap.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=Yp.getHeight(t))})),window.innerHeight-t-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Ap.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");Yp.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Yp.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",Yp.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",Yp.addClass(i,"button"),Yp.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",Yp.addClass(r,"button"),Yp.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Yp.addClass(a,"button"),Yp.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Ap.each(e.load.remembered,(function(t,n){Mf(e,n,n===e.preset)})):Mf(e,hf,!1),Yp.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Rf(this)),e.folders={},Ap.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Rf(this),yf(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[hf]=Rf(this,!0)),this.load.remembered[e]=Rf(this),this.preset=e,Mf(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Ap.each(this.__controllers,(function(t){this.getRoot().load.remembered?Sf(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Ap.each(this.__folders,(function(e){e.revert(e)})),e||yf(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&Cf(this.__listening)},updateDisplay:function(){Ap.each(this.__controllers,(function(e){e.updateDisplay()})),Ap.each(this.__folders,(function(e){e.updateDisplay()}))}});var Pf=vf;const Lf=(()=>{const e=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"})();console.log(Lf);const Df="mobile"===Lf,If={},Nf=(e,t="#000000")=>{console.log(`Status information: ${e}`);const n=document.getElementById("status-line");n&&(n.innerText=e,n.style.setProperty("color",t))},Of=e=>{const t=Gf.collectMaterials();em.updateMaterialUI(Wf,t),Nf(`${e}`),Vf.sceneName=e.replace(/:/g,"_")},Uf=(e,t)=>{return n=void 0,i=void 0,a=function*(){let n=If[t];n||(yield Gf.loadResource(e+".glb",t,(e=>{}),((e,n)=>{n?(If[t]={scene:n,glb:!0},Of(e)):Nf(`load ${e}`,"#ff0000")})),n=If[t]),Nf(`render ${t}`,"#ff0000"),Gf.update(void 0,n.scene,n.glb),Of(t)},new((r=void 0)||(r=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function o(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(s,o)}l((a=a.apply(n,i||[])).next())}));var n,i,r,a},Ff=()=>{let e=1;switch(Vf.groundMaterial.toLocaleLowerCase()){default:e=1;break;case"parquet":e=3;break;case"pavement":e=4}Gf.setGroundMaterial(e)},Bf=document.getElementById("three_canvas"),zf=new rs({canvas:Bf,antialias:!0,alpha:!0,preserveDrawingBuffer:!0});zf.setPixelRatio(window.devicePixelRatio),zf.setSize(window.innerWidth,window.innerHeight),document.body.appendChild(zf.domElement);const kf=new class{constructor(e={}){const t=this;let n,i,r,a;const s={objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");function l(e,n,i){if(e.isCSS2DObject){ep.setFromMatrixPosition(e.matrixWorld),ep.applyMatrix4(np);const l=!0===e.visible&&ep.z>=-1&&ep.z<=1&&!0===e.layers.test(i.layers);if(e.element.style.display=!0===l?"":"none",!0===l){e.onBeforeRender(t,n,i);const s=e.element;s.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(ep.x*r+r)+"px,"+(-ep.y*a+a)+"px)",s.parentNode!==o&&o.appendChild(s),e.onAfterRender(t,n,i)}const d={distanceToCameraSquared:(c=i,h=e,ip.setFromMatrixPosition(c.matrixWorld),rp.setFromMatrixPosition(h.matrixWorld),ip.distanceToSquared(rp))};s.objects.set(e,d)}var c,h;for(let t=0,r=e.children.length;t{const i=new Uint8Array(1048576);for(let e=0;e{this.skyEnvironment.changeVisibility(!1),this.backgroundEnvironment.hideBackground(),this.showEnvironment=!0},r=e.toLowerCase();if(r.endsWith(".exr"))this.environmentLoader.loadExr(e,t,!0),n();else if(r.endsWith(".hdr"))this.environmentLoader.loadHdr(e,t,!0),n();else if(r.endsWith(".envmap"))this.environmentLoader.loadEnvmap(e,t,!0),n();else if(r.endsWith(".glb")||r.endsWith(".gltf")){i(e,null);const n=yield this.loadGLTF(t);i(e,n)}}catch(e){console.log(e)}}))}createControls(){var e;null!==(e=this.controls)&&void 0!==e||(this.controls=new tu(this.renderer,this.camera))}changeLightControls(e){var t;e&&!this.transformControls&&(this.transformControls=null===(t=this.controls)||void 0===t?void 0:t.addTransformControl(this.lightSources.getLightSources()[0],this.scene)),this.transformControls&&(this.transformControls.visible=e)}setEnvironment(){this.environmentLoader.loadDefaultEnvironment(!0,(()=>new hp({type:cp})),"room environment"),this.environmentLoader.loadDefaultEnvironment(!1,(()=>new hp({type:lp})),"front light environment"),this.environmentLoader.loadEnvmap("test64.envmap",xp,!1)}updateSceneDependencies(){this.sceneRenderer.bakedGroundContactShadow.needsUpdate=!0,this.updateBounds()}updateBounds(){this.sceneRenderer.updateBounds(this.sceneBounds,this.scaleShadowAndAo)}setGroundMaterial(e){this.groundMaterialType!==e&&(this.groundMaterialType=e,this.updateGround(void 0,dc(this.groundMaterialType)),this.sceneRenderer.clearCache())}updateGround(e,t){this.groundMesh||(this.groundMesh=new ni,this.groundMesh.name="groundMesh",this.groundMesh.userData.isFloor=!0,this.groundMesh.receiveShadow=!0,this.sceneRenderer.groundGroup.add(this.groundMesh)),e&&(this.groundMesh.geometry=e),t&&(t.depthWrite=!1,t.polygonOffset=!0,t.polygonOffsetFactor=4,t.polygonOffsetUnits=4,t.needsUpdate=!0,this.groundMesh.material=t,this.groundMesh.userData.isFloor=!0)}update(e,t,n){t&&this.setNewTurntableGroup(t,null!=n&&n),e&&this.properties.rotate!==(null==e?void 0:e.rotate)&&(this.properties.rotate=null==e?void 0:e.rotate,0===this.properties.rotate&&(this.turnTableGroup.rotation.y=0)),e&&this.properties.dimensions!==(null==e?void 0:e.dimensions)&&(this.properties.dimensions=null==e?void 0:e.dimensions,this.updateDimensions()),e&&this.properties.randomOrientation!==(null==e?void 0:e.randomOrientation)&&(this.properties.randomOrientation=null==e?void 0:e.randomOrientation)}updateDimensions(){if(this.properties.dimensions){if(0===this.dimensioningArrows.length)for(let e=0;e<3;++e){const e=new ap(new Qe,new Qe,{color:0,arrowPixelWidth:10,arrowPixelHeight:15,shaftPixelWidth:3,shaftPixelOffset:1,labelClass:"label",deviceRatio:window.devicePixelRatio});this.dimensioningArrows.push(e),this.dimensioningArrowScene.add(e)}const e=this.sceneRenderer.boundingVolume.bounds,t=this.sceneRenderer.boundingVolume.size,n=.2*Math.min(t.x,t.y,t.z);this.dimensioningArrows[0].setPosition(new Qe(e.min.x,e.min.y,e.max.z+n),new Qe(e.max.x,e.min.y,e.max.z+n)),this.dimensioningArrows[1].setPosition(new Qe(e.min.x-n,e.min.y,e.max.z+n),new Qe(e.min.x-n,e.max.y,e.max.z+n)),this.dimensioningArrows[2].setPosition(new Qe(e.min.x-n,e.min.y,e.max.z),new Qe(e.min.x-n,e.min.y,e.min.z))}else this.dimensioningArrows.forEach((e=>e.setLabel("")))}collectMaterials(){const e=[];return this.scene.traverse((t=>{if(t instanceof ni&&t.name.length>0){const n=t.material;n&&e.push({materialId:t.name,material:n})}else if(t instanceof ni&&t.material.name.length>0){const n=t.material;if(n){const i=t.material.name;-1===e.findIndex((e=>e.materialId===i))&&e.push({materialId:i,material:n})}}})),e}updateMaterialProperties(e,t){this.properties.materialNoise!==e.materialNoise&&(this.properties.materialNoise=e.materialNoise,t.forEach((e=>{const t=e.material;t.userData&&"ormMap"in t.userData||(t.roughnessMap=this.properties.materialNoise?this.noiseTexture:null,t.metalnessMap=this.properties.materialNoise?this.noiseTexture:null,t.needsUpdate=!0)})))}resize(e,t){var n;this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.sceneRenderer.setSize(e,t),null===(n=this.css2Renderer)||void 0===n||n.setSize(e,t)}animate(e){this.properties.rotate>0&&(this.turnTableGroup.rotation.y+=2*Math.PI*e*.001*this.properties.rotate)}prepareRender(e){var t,n;const i=this.environmentLoader.setEnvironment(this.scene,{showEnvironment:this.showEnvironment,environmentRotation:this.environmentRotation,environmentIntensity:this.environmentIntensity});if(i){null===(t=this.groundProjectionSkybox)||void 0===t||t.removeFromParent(),this.groundProjectionSkybox=null;const e=null===(n=this.environmentLoader.currentEnvironment)||void 0===n?void 0:n.equirectangularTexture;this.scene.userData.shadowFromEnvironment=!0,e&&(this.lightSources.currentLightSourceDefinition=Il.noLightSources,this.lightSources.updateLightSources(),this.createGroundProjectionSkybox&&(this.groundProjectionSkybox=new _p(e),this.groundProjectionSkybox.scale.setScalar(this.groundProjectionSkyboxDistance),this.groundProjectionSkybox.name="skybox",this.scene.add(this.groundProjectionSkybox)))}const r=this.createGroundProjectionSkybox&&this.groundProjectionSkybox?2*this.groundProjectionSkyboxDistance:void 0;if(this.sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(this.camera,r),i&&this.updateSceneDependencies(),this.sceneRenderer.outlineRenderer.parameters.enabled){this.raycaster.setFromCamera(e,this.camera);const t=this.raycaster.intersectObject(this.turnTableGroup,!0),n=t.length>0?t[0].object:void 0;this.sceneRenderer.selectObjects(n?[n]:[])}}render(e=!0){var t,n;e&&(null===(t=this.controls)||void 0===t||t.update()),this.backgroundEnvironment.update(this.sceneRenderer.width,this.sceneRenderer.height,this.camera),this.sceneRenderer.render(this.scene,this.camera),this.properties.dimensions&&(this.dimensioningArrows.forEach((e=>{e.arrowNeedsUpdate=!0})),this.renderer.autoClear=!1,this.renderer.render(this.dimensioningArrowScene,this.camera),null===(n=this.css2Renderer)||void 0===n||n.render(this.dimensioningArrowScene,this.camera),this.renderer.autoClear=!0)}loadGLTF(e){return yp(this,void 0,void 0,(function*(){const t=new Th;(new wh).setDecoderPath("three/examples/jsm/libs/draco/");const n=yield t.loadAsync(e);return this.updateGLTFScene(n,(e=>{if(e.isMesh){const t=e.material;t instanceof So&&!1===t.transparent&&(e.castShadow=!0,e.receiveShadow=!0)}})),this.setNewTurntableGroup(n.scene,!0),n.scene}))}updateGLTFScene(e,t){e.scene.traverse((e=>{e instanceof ni&&(t(e),e.material instanceof So&&(e.material.envMapIntensity=1,e.material.needsUpdate=!0))}))}setNewTurntableGroup(e,t){this.turnTableGroup.clear(),this.scaleShadowAndAo=t,this.setInitialObjectPosition(e),this.setInitialCameraPositionAndRotation(),this.sceneRenderer.environmentLights||this.lightSources.setLightSourcesDistances(this.sceneRenderer.boundingVolume,t),this.sceneRenderer.forceShadowUpdates(!0),this.updateSceneDependencies()}setInitialObjectPosition(e){e.updateMatrixWorld(),this.sceneBounds.setFromObject(e);const t=this.sceneBounds.getSize(new Qe),n=this.sceneBounds.getCenter(new Qe);e.applyMatrix4((new Rt).makeTranslation(-n.x,-this.sceneBounds.min.y,-n.z)),this.sceneBounds.translate(new Qe(-n.x,-this.sceneBounds.min.y-t.y/2,-n.z));const i=-t.y/2;this.turnTableGroup.position.y=i,this.turnTableGroup.add(e),this.turnTableGroup.updateMatrixWorld(),this.sceneRenderer.groundLevel=i}setInitialCameraPositionAndRotation(){const e=new Qe(-1.5,.8,2.5).normalize();if(this.properties.randomOrientation){const t=4*Math.random()-2,n=.8*Math.random()+.4;e.set(t,n,2.5).normalize()}this.camera.position.copy(e),this.camera.lookAt(new Qe(0,0,0)),this.camera.updateMatrixWorld();const t=(new tt).setFromObject(this.turnTableGroup).applyMatrix4(this.camera.matrixWorldInverse),n=this.camera.fov*Math.PI/180/2,i=this.camera.aspect,r=Math.max(-t.min.x/i,t.max.x/i,-t.min.y,t.max.y)/Math.tan(n)+t.max.z+1;this.camera.position.copy(e.multiplyScalar(r)),this.camera.lookAt(new Qe(0,0,0)),this.camera.updateMatrixWorld()}constructLoadingGeometry(e){let t=[];if(1===e){const e=[];for(let t=0;t<=230;t+=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)+1})}e.push({x:0,y:0});for(let t=60;t>=-180;t-=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)-1})}const n=.6,i=2.5*n,r=new ro(e.map((e=>new Qe(e.x,e.y+2+i,0)))),a=new xo(r,64,n,16,!1),s=new vo(n,32,16);s.translate(-1,3+i,0);const o=new vo(n,32,16);o.translate(1,1+i,0);const l=new vo(n,32,16),c=new wo({color:14352384,side:2});t=[{geometry:a,material:c,materialId:"",environment:!1},{geometry:s,material:c,materialId:"",environment:!1},{geometry:o,material:c,materialId:"",environment:!1},{geometry:l,material:c,materialId:"",environment:!1}]}else{const e=(()=>{const e=new So({side:2});return nc((t=>e.map=t),cc,new vn(.9,.9,.9)),e})();t=[{geometry:new ri,material:e,materialId:"",environment:!1}]}return(e=>{const t=new Qa;return e.forEach((e=>{const n=new ni(e.geometry,e.material);e.transform&&n.applyMatrix4(e.transform),n.castShadow=!e.environment,n.receiveShadow=!0,t.add(n)})),t})(t)}}(zf,kf);Gf.sceneRenderer.setQualityLevel(Df?Ju.LOW:Ju.HIGHEST),Gf.createControls(),Gf.setEnvironment(),Gf.updateSceneDependencies(),Ff();const Wf=new Pf,jf=Object.assign({},...t.map((e=>({[e.name]:e.url})))),Xf=Wf.add(Vf,"glb",jf).onChange((e=>{if(""!==e){const n=t.findIndex((t=>t.url===e)),i=n>=0?t[n].name:e;Uf(i,e)}}));Wf.add(Vf,"randomOrientation").onChange((()=>Gf.update(Vf))),Wf.add(Vf,"dimensions").onChange((()=>Gf.update(Vf))),Wf.add(Vf,"groundMaterial",{"only shadow":"onlyshadow",parquet:"parquet",pavement:"pavement"}).onChange((()=>Ff()));const Yf=Wf.addFolder("environment"),qf=Yf.add(Gf,"showEnvironment").onChange((e=>{e&&(Kf.hideSky(),Qf.hideBackground())}));Yf.add(Gf,"environmentRotation",0,2*Math.PI,.01).onChange((e=>{var t;(null===(t=Gf.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(Gf.scene.userData.environmentDefinition.rotation=e)})),Yf.add(Gf,"environmentIntensity",0,5,.01).onChange((e=>{var t;(null===(t=Gf.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(Gf.scene.userData.environmentDefinition.intensity=e)}));const Zf=Yf.addFolder("sky"),Kf=new class{constructor(e){this.skyEnvironment=e}hideSky(){var e,t;null===(e=this.showSkyController)||void 0===e||e.setValue(!1),null===(t=this.showSkyController)||void 0===t||t.updateDisplay()}addGUI(e,t){this.showSkyController=e.add(this.skyEnvironment.parameters,"visible").onChange((()=>{this.skyEnvironment.updateSky(),t&&t(this.skyEnvironment)}))}}(Gf.skyEnvironment);Kf.addGUI(Zf,(e=>{e.parameters.visible&&(qf.setValue(!1),qf.updateDisplay(),Qf.hideBackground())}));const Jf=Yf.addFolder("background"),Qf=new class{constructor(e){this._backgroundEnvironment=e}hideBackground(){var e,t;null===(e=this._backgroundTypeController)||void 0===e||e.setValue("None"),null===(t=this._backgroundTypeController)||void 0===t||t.updateDisplay()}addGUI(e,t){const n={backgroundType:""},i=new Map([["None",ah.None],["Grid Paper",ah.GridPaper],["Concrete",ah.Concrete],["Marble",ah.Marble],["Granite",ah.Granite],["Vorocracks Marble",ah.VorocracksMarble],["Kraft",ah.Kraft],["Line (slow)",ah.Line],["Test",ah.Test]]),r=[];i.forEach(((e,t)=>{r.push(t),this._backgroundEnvironment.parameters.backgroundType===e&&(n.backgroundType=t)})),e.add(n,"backgroundType",r).onChange((e=>{var n;i.has(e)&&(this._backgroundEnvironment.parameters.backgroundType=null!==(n=i.get(e))&&void 0!==n?n:ah.None,this._backgroundEnvironment.updateBackground(),t&&t(this._backgroundEnvironment))}))}}(Gf.backgroundEnvironment);Qf.addGUI(Jf,(e=>{e.parameters.isSet&&(qf.setValue(!1),qf.updateDisplay(),Kf.hideSky())})),Gf.environmentLoader.addGUI(Yf);const $f=new class{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const i=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(i,t);const r=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(r,t);const a=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(a,t);const s=e.addFolder("Outline");this._addOutlineGUI(s,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",J],["SRGBColorSpace",K]]),i=[];n.forEach(((e,t)=>{i.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)})),e.add(this._sceneRenderer,"outputColorSpace",i).onChange((e=>{var i;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(i=n.get(e))&&void 0!==i?i:K,t())}));const r=new Map([["NoToneMapping",h],["LinearToneMapping",d],["ReinhardToneMapping",u],["CineonToneMapping",p],["ACESFilmicToneMapping",f]]),a=[];r.forEach(((e,t)=>{a.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)})),e.add(this._sceneRenderer,"toneMapping",a).onChange((e=>{var n;r.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=r.get(e))&&void 0!==n?n:h,t())}))}_addDebugGUI(e,t){const n=new Map([["HIGHEST",Ju.HIGHEST],["HIGH",Ju.HIGH],["MEDIUM",Ju.MEDIUM],["LOW",Ju.LOW]]),i=[];n.forEach(((e,t)=>i.push(t))),e.add(this,"_qualityLevel",i).onChange((e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:Ju.HIGHEST)})),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow Monte Carlo":"shadow","shadow blur":"shadowblur","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","ground reflection":"groundreflection","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange((()=>t()))}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadow.shadowConfiguration,i=[];n.types.forEach(((e,t)=>{i.push(t)}));const r=()=>{this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",i).onChange((e=>{this._sceneRenderer.screenSpaceShadow.switchType(e)&&(a.object=n.currentConfiguration,s.object=n.currentConfiguration,o.object=n.currentConfiguration,a.updateDisplay(),s.updateDisplay(),o.updateDisplay(),r())}));const a=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange((()=>r())),s=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange((()=>r())),o=e.add(n.currentConfiguration,"radius",0,100).onChange((()=>r()))}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.gBufferRenderTarget.needsUpdate=!0,this._sceneRenderer.screenSpaceShadow.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,this._sceneRenderer.shadowAndAoPass.shadowAndAoRenderTargets.parametersNeedsUpdate=!0,t()},i=this._sceneRenderer.shadowAndAoPass.parameters,r=i.shadow,a=this._sceneRenderer.screenSpaceShadow.parameters,s=i.ao,o=i.poissonDenoise;e.add(i,"enabled").onChange((()=>n()));const l=new Map([["none",null],["SSAO",0],["SAO",1],["N8AO",2],["HBAO",3],["GTAO",4]]),c=Array.from(l.keys());l.forEach(((e,t)=>{e===s.algorithm&&(this._ambientOcclusionType=t)})),e.add(i,"aoIntensity",0,1).onChange((()=>{n()})),e.add(i,"aoOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowIntensity",0,1).onChange((()=>n())),e.add(i,"alwaysUpdate").onChange((()=>n())),e.add(i,"progressiveDenoiseIterations",0,3,1).onChange((()=>n()));const h=e.addFolder("Shadow and Monte Carlo integration");h.add(a,"maximumNumberOfLightSources",-1,10,1).onChange((()=>n())),h.add(a,"enableGroundBoundary").onChange((()=>n())),h.add(a,"directionalDependency",0,1,.01).onChange((()=>n())),h.add(a,"directionalExponent",0,2,.01).onChange((()=>n())),h.add(a,"groundBoundary",0,1,.01).onChange((()=>n())),h.add(a,"fadeOutDistance",0,5,.01).onChange((()=>n())),h.add(a,"fadeOutBlur",0,20,1).onChange((()=>n())),h.add(r,"shadowRadius",.001,.5).onChange((()=>n()));const d=e.addFolder("AO");d.add(this,"_ambientOcclusionType",c).onChange((e=>{if(l.has(e)){const t=l.get(e);s.algorithm=void 0!==t?t:0,n()}})),d.add(s,"samples",1,64,1).onChange((()=>n())),d.add(s,"radius",.01,2,.01).onChange((()=>n())),d.add(s,"distanceExponent",.1,4,.1).onChange((()=>n())),d.add(s,"thickness",.01,2,.01).onChange((()=>n())),d.add(s,"distanceFallOff",0,1).onChange((()=>n())),d.add(s,"scale",.01,2,.01).onChange((()=>n())),d.add(s,"bias",1e-4,.01,1e-4).onChange((()=>n())),d.add(s,"screenSpaceRadius").onChange((()=>n()));const u=e.addFolder("Possion Denoise");u.add(o,"iterations",0,4,1).onChange((()=>n())),u.add(o,"samples",0,32,1).onChange((()=>n())),u.add(o,"rings",0,16,.125).onChange((()=>n())),u.add(o,"radiusExponent",.1,4,.01).onChange((()=>n())),u.add(o,"radius",0,50,1).onChange((()=>n())),u.add(o,"lumaPhi",0,20,.001).onChange((()=>n())),u.add(o,"depthPhi",0,20,.001).onChange((()=>n())),u.add(o,"normalPhi",0,20,.001).onChange((()=>n()))}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange((()=>t())),e.add(n,"fadeOutDistance",0,4).onChange((()=>t())),e.add(n,"fadeOutExponent",.1,10).onChange((()=>t())),e.add(n,"brightness",0,2).onChange((()=>t())),e.add(n,"blurHorizontal",0,10).onChange((()=>t())),e.add(n,"blurVertical",0,10).onChange((()=>t()))}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadow.applyParameters(),t()},i=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(i,"enabled"),e.add(i,"cameraHelper").onChange((()=>n())),e.add(i,"alwaysUpdate"),e.add(i,"fadeIn"),e.add(i,"blurMin",0,.2,.001).onChange((()=>n())),e.add(i,"blurMax",0,.5,.01).onChange((()=>n())),e.add(i,"fadeoutFalloff",0,1,.01).onChange((()=>n())),e.add(i,"fadeoutBias",0,.5).onChange((()=>n())),e.add(i,"opacity",0,1,.01).onChange((()=>n())),e.add(i,"maximumPlaneSize",0,50,1).onChange((()=>n())),e.add(i,"cameraFar",.1,10,.1).onChange((()=>n()))}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},i=this._sceneRenderer.outlineRenderer.parameters;e.add(i,"enabled"),e.add(i,"edgeStrength",.5,20).onChange((()=>n())),e.add(i,"edgeGlow",0,20).onChange((()=>n())),e.add(i,"edgeThickness",.5,20).onChange((()=>n())),e.add(i,"pulsePeriod",0,5).onChange((()=>n())),e.addColor(i,"visibleEdgeColor").onChange((()=>n())),e.addColor(i,"hiddenEdgeColor").onChange((()=>n()))}}(Gf.sceneRenderer);$f.addGUI(Wf,(()=>{}));const em=new Sp,tm=Wf.addFolder("Light"),nm=new class{constructor(e){this.lightColors=[],this.lightSourceFolders=[],this.lights="none",this.lightSources=e}addGUI(e,t,n){e.add(this.lightSources,"lightControls").onChange(t),e.add(this,"lights",["none","default","fife"]).onChange((e=>{switch(e){default:case"none":this.lightSources.currentLightSourceDefinition=Il.noLightSources;break;case"default":this.lightSources.currentLightSourceDefinition=Il.defaultLightSources;break;case"fife":this.lightSources.currentLightSourceDefinition=Il.fifeLightSources}this.lightSources.updateLightSources(),this.updateGUI(),n()})),this.lightGUI=e,this.updateGUI()}updateGUI(){if(!this.lightGUI)return;const e=this.lightGUI;this.lightSourceFolders.forEach((t=>e.removeFolder(t))),this.lightSourceFolders=[],this.lightColors=[],this.lightSources.getLightSources().forEach((t=>{if(t instanceof fl){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Ambient Light");this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(5).step(.1),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new vn(e)))}})),this.lightSources.getLightSources().forEach((t=>{var n;if(t instanceof pl){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Directional Light "+(this.lightColors.length-1));this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(10).step(.1),n.add(t,"castShadow"),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new vn(e)))}else if(t instanceof ml){this.lightColors.push({color:t.color.getHex()});const i=e.addFolder("Rect area Light "+(this.lightColors.length-1));this.lightSourceFolders.push(i);const r=null===(n=this.lightSources.sceneRenderer)||void 0===n?void 0:n.screenSpaceShadow.findShadowLightSource(t);i.add(t,"visible"),i.add(t,"intensity").min(0).max(200).step(1),r&&i.add(r,"castShadow"),i.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new vn(e)))}}))}}(Gf.getLightSources());nm.addGUI(tm,(()=>e=>Gf.changeLightControls(e)),(()=>Gf.updateSceneDependencies())),window.addEventListener("resize",(()=>{const e=window.innerWidth,t=window.innerHeight;Gf.resize(e,t)}),!1);const im=new Me;zf.domElement.addEventListener("pointermove",(e=>{!1!==e.isPrimary&&(im.x=e.clientX/window.innerWidth*2-1,im.y=-e.clientY/window.innerHeight*2+1)})),((e,t,n)=>{const i=document.getElementById("holder");i&&(i.ondragover=function(){return this.className="hover",!1},i.ondragend=function(){return this.className="",!1},i.ondrop=function(e){this.className="",e.preventDefault();const t=e.dataTransfer.files[0],n=new FileReader;n.onload=e=>((e,t)=>{((e,t)=>{const n=If[e];n?(Nf(`render ${e}`,"#ff0000"),Gf.update(void 0,n.scene,n.glb),Of(e)):Gf.loadResource(e,t,(e=>{}),((t,n)=>{n?(If[e]={scene:n,glb:!0},Of(t),(e=>{jf.push(e);let t="";jf.forEach((e=>{t+=""})),Xf.domElement.children[0].innerHTML=t,Xf.setValue(e),Xf.updateDisplay()})(e)):Nf(`load ${t}`,"#ff0000")}))})(e.name,t.target.result)})(t,e),n.readAsDataURL(t)})})();const rm=document.createElement("a"),am=e=>{const t=zf.domElement.toDataURL();rm.href=t,rm.download=e,rm.click()},sm=(e,t)=>{const n=Gf.sceneRenderer.debugOutput;Gf.sceneRenderer.debugOutput=e,Gf.prepareRender(new Me),Gf.render(!1),am(t),Gf.sceneRenderer.debugOutput=n},om=document.getElementById("save-button");om&&(om.onclick=()=>(()=>{try{am(Vf.sceneName+".png")}catch(e){console.log(e)}})());const lm=document.getElementById("save-g-buffer-button");let cm,hm;lm&&(lm.onclick=()=>(()=>{try{sm("color",Vf.sceneName+"_color.png"),sm("g-normal",Vf.sceneName+"_normal.png"),sm("g-depth",Vf.sceneName+"_depth.png")}catch(e){console.log(e)}})());const dm=e=>{void 0===cm&&(cm=e),void 0===hm&&(hm=e);const t=e-hm;hm=e,Gf.animate(t),um(),requestAnimationFrame(dm)},um=()=>{Gf.prepareRender(im),Gf.render(),Hf.update()};(e=>{const n=t.findIndex((e=>"BrainStem"===e.name));if(n>=0){const e=t[n];Uf(e.name,e.url)}})(),requestAnimationFrame(dm)})(); \ No newline at end of file diff --git a/deploy/index.html b/deploy/index.html index 2d3043d..fe8a757 100644 --- a/deploy/index.html +++ b/deploy/index.html @@ -1,59 +1,65 @@ - + - - - - Three.js GLTF/GLB viewer - - - - + + + + Three.js GLTF/GLB viewer + + + - - -
-
-
.exr
.hdr
.envmap

.glb
.gltf
- - -
- - - \ No newline at end of file + +
+
+
+ .exr
.hdr
.envmap

.glb
.gltf +
+ + +
+ + + diff --git a/dist/client/index.html b/dist/client/index.html index 2d3043d..fe8a757 100644 --- a/dist/client/index.html +++ b/dist/client/index.html @@ -1,59 +1,65 @@ - + - - - - Three.js GLTF/GLB viewer - - - - + + + + Three.js GLTF/GLB viewer + + + - - -
-
-
.exr
.hdr
.envmap

.glb
.gltf
- - -
- - - \ No newline at end of file + +
+
+
+ .exr
.hdr
.envmap

.glb
.gltf +
+ + +
+ + + diff --git a/package-lock.json b/package-lock.json index dafa44b..bf24cfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,16 +12,23 @@ "dependencies": { "express": "^4.18.2", "lodash": "^4.17.21", - "three": "0.159.0" + "three": "0.160.0" }, "devDependencies": { "@types/dat.gui": "^0.7.12", "@types/express": "^4.17.21", - "@types/node": "^20.10.4", + "@types/node": "^20.10.5", "@types/three": "^0.159.0", + "@typescript-eslint/eslint-plugin": "6.15.0", + "@typescript-eslint/parser": "6.15.0", "axios": "^1.6.2", "copyfiles": "^2.4.1", "dat.gui": "^0.7.9", + "eslint": "8.56.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-jest": "27.6.0", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-prettier": "5.1.1", "install-peers": "^1.0.4", "npm-check-updates": "^16.14.12", "patch-package": "^8.0.0", @@ -34,6 +41,15 @@ "webpack-merge": "^5.10.0" } }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -53,12 +69,101 @@ "node": ">=10.0.0" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", + "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", "dev": true }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", + "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", + "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", + "dev": true + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -76,6 +181,18 @@ "node": ">=12" } }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, "node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -99,6 +216,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -229,6 +361,21 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@npmcli/git/node_modules/which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", + "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/@npmcli/installed-package-contents": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@npmcli/installed-package-contents/-/installed-package-contents-2.0.2.tgz", @@ -259,21 +406,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/@npmcli/move-file/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/@npmcli/node-gyp": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@npmcli/node-gyp/-/node-gyp-3.0.0.tgz", @@ -295,6 +427,21 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@npmcli/promise-spawn/node_modules/which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", + "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/@npmcli/run-script": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/@npmcli/run-script/-/run-script-6.0.2.tgz", @@ -311,6 +458,21 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@npmcli/run-script/node_modules/which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", + "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -321,6 +483,44 @@ "node": ">=14" } }, + "node_modules/@pkgr/utils": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/@pkgr/utils/-/utils-2.4.2.tgz", + "integrity": "sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "fast-glob": "^3.3.0", + "is-glob": "^4.0.3", + "open": "^9.1.0", + "picocolors": "^1.0.0", + "tslib": "^2.6.0" + }, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/@pkgr/utils/node_modules/open": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/open/-/open-9.1.0.tgz", + "integrity": "sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==", + "dev": true, + "dependencies": { + "default-browser": "^4.0.0", + "define-lazy-prop": "^3.0.0", + "is-inside-container": "^1.0.0", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@pnpm/config.env-replace": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@pnpm/config.env-replace/-/config.env-replace-1.1.0.tgz", @@ -534,9 +734,9 @@ "dev": true }, "node_modules/@types/eslint": { - "version": "8.44.9", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.44.9.tgz", - "integrity": "sha512-6yBxcvwnnYoYT1Uk2d+jvIfsuP4mb2EdIxFnrPABj5a/838qe5bGkNLFOiipX4ULQ7XVQvTxOh7jO+BTAiqsEw==", + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.0.tgz", + "integrity": "sha512-FlsN0p4FhuYRjIxpbdXovvHQhtlG05O1GG/RNWvdAxTboR438IOTwmrY/vLA+Xfgg06BTkP045M3vpFwTMv1dg==", "dev": true, "dependencies": { "@types/estree": "*", @@ -617,9 +817,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.10.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.4.tgz", - "integrity": "sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==", + "version": "20.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", + "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -635,9 +835,9 @@ } }, "node_modules/@types/qs": { - "version": "6.9.10", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.10.tgz", - "integrity": "sha512-3Gnx08Ns1sEoCrWssEgTSJs/rsT2vhGP+Ja9cnnk9k4ALxinORlQneLXFeFKOTJMOeZUFD1s7w+w2AphTpvzZw==", + "version": "6.9.11", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.11.tgz", + "integrity": "sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ==", "dev": true }, "node_modules/@types/range-parser": { @@ -652,6 +852,12 @@ "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", "dev": true }, + "node_modules/@types/semver": { + "version": "7.5.6", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", + "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==", + "dev": true + }, "node_modules/@types/send": { "version": "0.17.4", "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", @@ -724,6 +930,201 @@ "@types/node": "*" } }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.15.0.tgz", + "integrity": "sha512-j5qoikQqPccq9QoBAupOP+CBu8BaJ8BLjaXSioDISeTZkVO3ig7oSIKh3H+rEpee7xCXtWwSB4KIL5l6hWZzpg==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.15.0", + "@typescript-eslint/type-utils": "6.15.0", + "@typescript-eslint/utils": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.15.0.tgz", + "integrity": "sha512-MkgKNnsjC6QwcMdlNAel24jjkEO/0hQaMDLqP4S9zq5HBAUJNQB6y+3DwLjX7b3l2b37eNAxMPLwb3/kh8VKdA==", + "dev": true, + "dependencies": { + "@typescript-eslint/scope-manager": "6.15.0", + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/typescript-estree": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.15.0.tgz", + "integrity": "sha512-+BdvxYBltqrmgCNu4Li+fGDIkW9n//NrruzG9X1vBzaNK+ExVXPoGB71kneaVw/Jp+4rH/vaMAGC6JfMbHstVg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.15.0.tgz", + "integrity": "sha512-CnmHKTfX6450Bo49hPg2OkIm/D/TVYV7jO1MCfPYGwf6x3GO0VU8YMO5AYMn+u3X05lRRxA4fWCz87GFQV6yVQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.15.0", + "@typescript-eslint/utils": "6.15.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.15.0.tgz", + "integrity": "sha512-yXjbt//E4T/ee8Ia1b5mGlbNj9fB9lJP4jqLbZualwpP2BCQ5is6BcWwxpIsY4XKAhmdv3hrW92GdtJbatC6dQ==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.15.0.tgz", + "integrity": "sha512-7mVZJN7Hd15OmGuWrp2T9UvqR2Ecg+1j/Bp1jXUEY2GZKV6FXlOIoqVDmLpBiEiq3katvj/2n2mR0SDwtloCew==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/visitor-keys": "6.15.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.15.0.tgz", + "integrity": "sha512-eF82p0Wrrlt8fQSRL0bGXzK5nWPRV2dYQZdajcfzOD9+cQz9O7ugifrJxclB+xVOvWvagXfqS4Es7vpLP4augw==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.15.0", + "@typescript-eslint/types": "6.15.0", + "@typescript-eslint/typescript-estree": "6.15.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.15.0.tgz", + "integrity": "sha512-1zvtdC1a9h5Tb5jU9x3ADNXO9yjP8rXlaoChu0DQX40vf5ACVpYIVIZhIMZ6d5sDXH7vq4dsZBT1fEGj8D2n2w==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.15.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", @@ -971,6 +1372,15 @@ "acorn": "^8" } }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -983,29 +1393,6 @@ "node": ">= 6.0.0" } }, - "node_modules/agent-base/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/agent-base/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/agentkeepalive": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", @@ -1117,24 +1504,24 @@ } }, "node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" + "node": ">=8" } }, "node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, "engines": { - "node": ">=12" + "node": ">=8" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" @@ -1253,6 +1640,15 @@ "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==", "dev": true }, + "node_modules/big-integer": { + "version": "1.6.52", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz", + "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, "node_modules/big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -1294,6 +1690,19 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/bonjour-service": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.1.1.tgz", @@ -1334,6 +1743,30 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/boxen/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/boxen/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/boxen/node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -1357,6 +1790,45 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/boxen/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/boxen/node_modules/type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/bplist-parser": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", + "integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==", + "dev": true, + "dependencies": { + "big-integer": "^1.6.44" + }, + "engines": { + "node": ">= 5.10.0" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1426,6 +1898,21 @@ "semver": "^7.0.0" } }, + "node_modules/bundle-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-3.0.0.tgz", + "integrity": "sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==", + "dev": true, + "dependencies": { + "run-applescript": "^5.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -1552,6 +2039,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/camelcase": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz", @@ -1565,9 +2061,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001570", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001570.tgz", - "integrity": "sha512-+3e0ASu4sw1SWaoCtvPeyXp+5PsjigkSt8OXZbF9StH5pQWbxEjLAZE3n8Aup5udop1uRiKA7a4utUk/uoSpUw==", + "version": "1.0.30001571", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001571.tgz", + "integrity": "sha512-tYq/6MoXhdezDLFZuCO/TKboTzuQ/xR5cFdgXPfDtM7/kchBO3b4VWghE/OAi/DV7tTdhmLjZiZBZi1fA/GheQ==", "dev": true, "funding": [ { @@ -1585,12 +2081,16 @@ ] }, "node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" + "node": ">=10" }, "funding": { "url": "https://github.com/chalk/chalk?sponsor=1" @@ -1623,6 +2123,18 @@ "fsevents": "~2.3.2" } }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/chownr": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", @@ -1703,42 +2215,6 @@ "wrap-ansi": "^7.0.0" } }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/cliui/node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -1863,6 +2339,21 @@ "node": ">= 0.8" } }, + "node_modules/compression/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/compression/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, "node_modules/compression/node_modules/safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -1996,21 +2487,6 @@ "node": ">= 8" } }, - "node_modules/cross-spawn/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/crypto-random-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-4.0.0.tgz", @@ -2045,11 +2521,20 @@ "dev": true }, "node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, "dependencies": { - "ms": "2.0.0" + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, "node_modules/decompress-response": { @@ -2088,26 +2573,176 @@ "node": ">=4.0.0" } }, - "node_modules/default-gateway": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-6.0.3.tgz", - "integrity": "sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg==", + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "node_modules/default-browser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-4.0.0.tgz", + "integrity": "sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==", "dev": true, "dependencies": { - "execa": "^5.0.0" + "bundle-name": "^3.0.0", + "default-browser-id": "^3.0.0", + "execa": "^7.1.1", + "titleize": "^3.0.0" }, "engines": { - "node": ">= 10" + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/defer-to-connect": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", - "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "node_modules/default-browser-id": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-3.0.0.tgz", + "integrity": "sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==", "dev": true, + "dependencies": { + "bplist-parser": "^0.2.0", + "untildify": "^4.0.0" + }, "engines": { - "node": ">=10" - } + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/execa": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", + "integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.1", + "human-signals": "^4.3.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^3.0.7", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": "^14.18.0 || ^16.14.0 || >=18.0.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/default-browser/node_modules/human-signals": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", + "integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==", + "dev": true, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/default-browser/node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/npm-run-path": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", + "integrity": "sha512-W4/tgAXFqFA0iL7fk0+uQ3g7wkL8xJmx3XdK0VGb4cHW//eZTtKGvFBBoRKVTpY7n6ze4NL9ly7rgXcHufqXKg==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-gateway": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-6.0.3.tgz", + "integrity": "sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg==", + "dev": true, + "dependencies": { + "execa": "^5.0.0" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "dev": true, + "engines": { + "node": ">=10" + } }, "node_modules/define-data-property": { "version": "1.1.1", @@ -2123,12 +2758,15 @@ } }, "node_modules/define-lazy-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", - "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", "dev": true, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/delayed-stream": { @@ -2199,6 +2837,18 @@ "node": ">=6" } }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/dot-prop": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-6.0.1.tgz", @@ -2226,9 +2876,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.614", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.614.tgz", - "integrity": "sha512-X4ze/9Sc3QWs6h92yerwqv7aB/uU8vCjZcrMjA8N9R1pjMFRe44dLsck5FzLilOYvcXuDn93B+bpGYyufc70gQ==", + "version": "1.4.616", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.616.tgz", + "integrity": "sha512-1n7zWYh8eS0L9Uy+GskE0lkBUNK83cXTVJI0pU3mGprFsbfSdAc15VTFbo+A+Bq4pwstmL30AVcEU3Fo463lNg==", "dev": true }, "node_modules/emoji-regex": { @@ -2237,129 +2887,501 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, - "node_modules/emojis-list": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", - "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "node_modules/emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/encoding": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", + "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, + "optional": true, + "dependencies": { + "iconv-lite": "^0.6.2" + } + }, + "node_modules/encoding/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "optional": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/enhanced-resolve": { + "version": "5.15.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", + "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/envinfo": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.0.tgz", + "integrity": "sha512-G9/6xF1FPbIw0TtalAMaVPpiq2aDEuKLXM314jPVAO9r2fo2a4BLqMNkmRS7O/xPPZ+COAhGIz3ETvHEV3eUcg==", + "dev": true, + "bin": { + "envinfo": "dist/cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/err-code": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", + "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", + "dev": true + }, + "node_modules/es-module-lexer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.4.1.tgz", + "integrity": "sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==", + "dev": true + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-goat": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-goat/-/escape-goat-4.0.0.tgz", + "integrity": "sha512-2Sd4ShcWxbx6OY1IHyla/CVNwvg7XwZVoXZHcSu9w9SReNP1EzzD5T8NWKIR38fIqEns9kDWKUQTXXAmlDrdPg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "8.56.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", + "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.56.0", + "@humanwhocodes/config-array": "^0.11.13", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-es": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", + "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", + "dev": true, + "dependencies": { + "eslint-utils": "^2.0.0", + "regexpp": "^3.0.0" + }, + "engines": { + "node": ">=8.10.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=4.19.1" + } + }, + "node_modules/eslint-plugin-jest": { + "version": "27.6.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.6.0.tgz", + "integrity": "sha512-MTlusnnDMChbElsszJvrwD1dN3x6nZl//s4JD23BxB6MgR66TZlL064su24xEIS3VACfAoHV1vgyMgPw8nkdng==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "^5.10.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^5.0.0 || ^6.0.0", + "eslint": "^7.0.0 || ^8.0.0", + "jest": "*" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + }, + "jest": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-jest/node_modules/@typescript-eslint/scope-manager": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", + "integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-jest/node_modules/@typescript-eslint/types": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz", + "integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-jest/node_modules/@typescript-eslint/typescript-estree": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz", + "integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/visitor-keys": "5.62.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-jest/node_modules/@typescript-eslint/utils": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz", + "integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.62.0", + "@typescript-eslint/types": "5.62.0", + "@typescript-eslint/typescript-estree": "5.62.0", + "eslint-scope": "^5.1.1", + "semver": "^7.3.7" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/eslint-plugin-jest/node_modules/@typescript-eslint/visitor-keys": { + "version": "5.62.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz", + "integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "5.62.0", + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/eslint-plugin-jest/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/eslint-plugin-jest/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true, "engines": { - "node": ">= 4" + "node": ">=4.0" } }, - "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "node_modules/eslint-plugin-node": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", + "integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==", + "dev": true, + "dependencies": { + "eslint-plugin-es": "^3.0.0", + "eslint-utils": "^2.0.0", + "ignore": "^5.1.1", + "minimatch": "^3.0.4", + "resolve": "^1.10.1", + "semver": "^6.1.0" + }, "engines": { - "node": ">= 0.8" + "node": ">=8.10.0" + }, + "peerDependencies": { + "eslint": ">=5.16.0" } }, - "node_modules/encoding": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", - "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "node_modules/eslint-plugin-node/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, - "optional": true, - "dependencies": { - "iconv-lite": "^0.6.2" + "bin": { + "semver": "bin/semver.js" } }, - "node_modules/encoding/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "node_modules/eslint-plugin-prettier": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.1.tgz", + "integrity": "sha512-WQpV3mSmIobb77s4qiCZu3dBrZZ0rj8ckSfBtRrgNK9Wnh2s3eiaxNTWloz1LJ1WtvqZES/PAI7PLvsrGt/CEA==", "dev": true, - "optional": true, "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.8.5" }, "engines": { - "node": ">=0.10.0" + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } } }, - "node_modules/enhanced-resolve": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", - "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" }, "engines": { - "node": ">=10.13.0" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/env-paths": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", - "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "node_modules/eslint-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, + "dependencies": { + "eslint-visitor-keys": "^1.1.0" + }, "engines": { "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" } }, - "node_modules/envinfo": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.0.tgz", - "integrity": "sha512-G9/6xF1FPbIw0TtalAMaVPpiq2aDEuKLXM314jPVAO9r2fo2a4BLqMNkmRS7O/xPPZ+COAhGIz3ETvHEV3eUcg==", + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true, - "bin": { - "envinfo": "dist/cli.js" - }, "engines": { "node": ">=4" } }, - "node_modules/err-code": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", - "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", - "dev": true - }, - "node_modules/es-module-lexer": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.4.1.tgz", - "integrity": "sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==", - "dev": true - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, "engines": { - "node": ">=6" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/escape-goat": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-goat/-/escape-goat-4.0.0.tgz", - "integrity": "sha512-2Sd4ShcWxbx6OY1IHyla/CVNwvg7XwZVoXZHcSu9w9SReNP1EzzD5T8NWKIR38fIqEns9kDWKUQTXXAmlDrdPg==", + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, "engines": { - "node": ">=12" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://opencollective.com/eslint" } }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" - }, - "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" + "estraverse": "^5.1.0" }, "engines": { - "node": ">=8.0.0" + "node": ">=0.10" } }, "node_modules/esrecurse": { @@ -2374,7 +3396,7 @@ "node": ">=4.0" } }, - "node_modules/esrecurse/node_modules/estraverse": { + "node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", @@ -2383,13 +3405,13 @@ "node": ">=4.0" } }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, "engines": { - "node": ">=4.0" + "node": ">=0.10.0" } }, "node_modules/etag": { @@ -2494,12 +3516,31 @@ "node": ">= 0.10.0" } }, + "node_modules/express/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/express/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -2516,12 +3557,30 @@ "node": ">=8.6.0" } }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, "node_modules/fast-memoize": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/fast-memoize/-/fast-memoize-2.5.2.tgz", @@ -2538,9 +3597,9 @@ } }, "node_modules/fastq": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", - "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", + "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -2564,6 +3623,18 @@ "integrity": "sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==", "dev": true }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -2593,6 +3664,19 @@ "node": ">= 0.8" } }, + "node_modules/finalhandler/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/finalhandler/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2627,6 +3711,26 @@ "flat": "cli.js" } }, + "node_modules/flat-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.9", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.9.tgz", + "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", + "dev": true + }, "node_modules/follow-redirects": { "version": "1.15.3", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", @@ -2821,27 +3925,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/gauge/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/gauge/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -2910,15 +3993,15 @@ } }, "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, "dependencies": { - "is-glob": "^4.0.1" + "is-glob": "^4.0.3" }, "engines": { - "node": ">= 6" + "node": ">=10.13.0" } }, "node_modules/glob-to-regexp": { @@ -2951,6 +4034,21 @@ "node": ">=10" } }, + "node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", @@ -3013,6 +4111,12 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/handle-thing": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.1.tgz", @@ -3227,29 +4331,6 @@ "node": ">= 6" } }, - "node_modules/http-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/http-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/http-proxy-middleware": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", @@ -3293,36 +4374,13 @@ "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dev": true, "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/https-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" + "agent-base": "6", + "debug": "4" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 6" } }, - "node_modules/https-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/human-signals": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", @@ -3397,6 +4455,22 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/import-lazy": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", @@ -3587,6 +4661,39 @@ "node": ">=0.10.0" } }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dev": true, + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container/node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-installed-globally": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.4.0.tgz", @@ -3764,6 +4871,21 @@ "node": ">= 10.13.0" } }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/jju": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", @@ -3830,6 +4952,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -3939,6 +5067,19 @@ "shell-quote": "^1.8.1" } }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/loader-runner": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", @@ -3982,6 +5123,12 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, "node_modules/lowercase-keys": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz", @@ -4377,9 +5524,10 @@ } }, "node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true }, "node_modules/multicast-dns": { "version": "7.2.5", @@ -4394,6 +5542,12 @@ "multicast-dns": "cli.js" } }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -4592,21 +5746,6 @@ "encoding": "^0.1.13" } }, - "node_modules/node-gyp/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/node-gyp/node_modules/ssri": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz", @@ -4643,21 +5782,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/node-gyp/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", @@ -4796,6 +5920,18 @@ "node": ">=14.14" } }, + "node_modules/npm-check-updates/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, "node_modules/npm-check-updates/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -4805,6 +5941,40 @@ "balanced-match": "^1.0.0" } }, + "node_modules/npm-check-updates/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/npm-check-updates/node_modules/glob": { + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/npm-check-updates/node_modules/minimatch": { "version": "9.0.3", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", @@ -4820,6 +5990,51 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/npm-check-updates/node_modules/rimraf": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", + "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", + "dev": true, + "dependencies": { + "glob": "^10.3.7" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/npm-check-updates/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/npm-check-updates/node_modules/strip-json-comments": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.1.tgz", + "integrity": "sha512-0fk9zBqO67Nq5M/m45qHCJxylV/DhBlIOVExqgOMiCCrzrhU6tCibRXNqE3jwJLftzE9SNuZtYbpzcO+i9FiKw==", + "dev": true, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/npm-install-checks": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-6.3.0.tgz", @@ -5023,6 +6238,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/optionator": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, + "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", @@ -5167,6 +6399,18 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/parse-github-url": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-github-url/-/parse-github-url-1.0.2.tgz", @@ -5217,37 +6461,6 @@ "npm": ">5" } }, - "node_modules/patch-package/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/patch-package/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "node_modules/patch-package/node_modules/rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -5266,19 +6479,7 @@ "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", "dev": true, "engines": { - "node": ">=6" - } - }, - "node_modules/patch-package/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" + "node": ">=6" } }, "node_modules/path-exists": { @@ -5435,6 +6636,43 @@ "node": ">=8" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "dev": true, + "peer": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/proc-log": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-3.0.0.tgz", @@ -5663,29 +6901,6 @@ "require-from-string": "^2.0.2" } }, - "node_modules/rc-config-loader/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/rc-config-loader/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/rc/node_modules/ini": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", @@ -5817,6 +7032,18 @@ "node": ">= 10.13.0" } }, + "node_modules/regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, "node_modules/registry-auth-token": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-5.0.2.tgz", @@ -5912,7 +7139,7 @@ "node": ">=8" } }, - "node_modules/resolve-from": { + "node_modules/resolve-cwd/node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", @@ -5921,6 +7148,15 @@ "node": ">=8" } }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/responselike": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz", @@ -5956,67 +7192,33 @@ } }, "node_modules/rimraf": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.5.tgz", - "integrity": "sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==", - "dev": true, - "dependencies": { - "glob": "^10.3.7" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/rimraf/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/rimraf/node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" + "glob": "^7.1.3" }, "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=16 || 14 >=14.17" + "rimraf": "bin.js" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/rimraf/node_modules/minimatch": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", - "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "node_modules/run-applescript": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz", + "integrity": "sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==", "dev": true, "dependencies": { - "brace-expansion": "^2.0.1" + "execa": "^5.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=12" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/run-parallel": { @@ -6174,6 +7376,19 @@ "node": ">= 0.8.0" } }, + "node_modules/send/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/send/node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, "node_modules/send/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -6206,6 +7421,15 @@ "node": ">= 0.8.0" } }, + "node_modules/serve-index/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, "node_modules/serve-index/node_modules/depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -6236,6 +7460,12 @@ "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true }, + "node_modules/serve-index/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, "node_modules/serve-index/node_modules/setprototypeof": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", @@ -6434,29 +7664,6 @@ "node": ">= 10" } }, - "node_modules/socks-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/socks-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -6550,29 +7757,6 @@ "wbuf": "^1.7.3" } }, - "node_modules/spdy-transport/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/spdy-transport/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/spdy-transport/node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", @@ -6596,29 +7780,6 @@ "safe-buffer": "~5.2.0" } }, - "node_modules/spdy/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/spdy/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/ssri": { "version": "10.0.5", "resolved": "https://registry.npmjs.org/ssri/-/ssri-10.0.5.tgz", @@ -6683,65 +7844,7 @@ "node": ">=8" } }, - "node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", + "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", @@ -6753,11 +7856,15 @@ "node": ">=8" } }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, "engines": { "node": ">=8" } @@ -6772,30 +7879,27 @@ } }, "node_modules/strip-json-comments": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.1.tgz", - "integrity": "sha512-0fk9zBqO67Nq5M/m45qHCJxylV/DhBlIOVExqgOMiCCrzrhU6tCibRXNqE3jwJLftzE9SNuZtYbpzcO+i9FiKw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, "engines": { - "node": ">=14.16" + "node": ">=8" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "dependencies": { "has-flag": "^4.0.0" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" + "node": ">=8" } }, "node_modules/supports-preserve-symlinks-flag": { @@ -6810,6 +7914,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/synckit": { + "version": "0.8.6", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.6.tgz", + "integrity": "sha512-laHF2savN6sMeHCjLRkheIU4wo3Zg9Ln5YOjOo7sZ5dVQW8yF5pPE5SIw1dsPhq3TRp1jisKRCdPhfs/1WMqDA==", + "dev": true, + "dependencies": { + "@pkgr/utils": "^2.4.2", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", @@ -6918,10 +8038,16 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, "node_modules/three": { - "version": "0.159.0", - "resolved": "https://registry.npmjs.org/three/-/three-0.159.0.tgz", - "integrity": "sha512-eCmhlLGbBgucuo4VEA9IO3Qpc7dh8Bd4VKzr7WfW4+8hMcIfoAVi1ev0pJYN9PTTsCslbcKgBwr2wNZ1EvLInA==" + "version": "0.160.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.160.0.tgz", + "integrity": "sha512-DLU8lc0zNIPkM7rH5/e1Ks1Z8tWCGRq6g8mPowdDJpw1CFBJMU7UoJjC6PefXW7z//SSl0b2+GCw14LB+uDhng==" }, "node_modules/through2": { "version": "2.0.5", @@ -6975,6 +8101,18 @@ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", "dev": true }, + "node_modules/titleize": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/titleize/-/titleize-3.0.0.tgz", + "integrity": "sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -7007,6 +8145,18 @@ "node": ">=0.6" } }, + "node_modules/ts-api-utils": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", + "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-loader": { "version": "9.5.1", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.5.1.tgz", @@ -7027,37 +8177,6 @@ "webpack": "^5.0.0" } }, - "node_modules/ts-loader/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/ts-loader/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "node_modules/ts-loader/node_modules/source-map": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", @@ -7067,18 +8186,33 @@ "node": ">= 8" } }, - "node_modules/ts-loader/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "dev": true + }, + "node_modules/tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "dev": true, "dependencies": { - "has-flag": "^4.0.0" + "tslib": "^1.8.1" }, "engines": { - "node": ">=8" + "node": ">= 6" + }, + "peerDependencies": { + "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, + "node_modules/tsutils/node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, "node_modules/tuf-js": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/tuf-js/-/tuf-js-1.1.7.tgz", @@ -7093,36 +8227,25 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/tuf-js/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "dependencies": { - "ms": "2.1.2" + "prelude-ls": "^1.2.1" }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">= 0.8.0" } }, - "node_modules/tuf-js/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/type-fest": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", - "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, "engines": { - "node": ">=12.20" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -7291,6 +8414,18 @@ "url": "https://github.com/yeoman/update-notifier?sponsor=1" } }, + "node_modules/update-notifier/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -7630,6 +8765,15 @@ "ajv": "^8.8.2" } }, + "node_modules/webpack-dev-server/node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/webpack-dev-server/node_modules/ipaddr.js": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.1.0.tgz", @@ -7662,21 +8806,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/webpack-dev-server/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/webpack-dev-server/node_modules/schema-utils": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.2.0.tgz", @@ -7719,6 +8848,28 @@ "node": ">=10.13.0" } }, + "node_modules/webpack/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/webpack/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/webpack/node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -7749,18 +8900,18 @@ } }, "node_modules/which": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", - "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "dependencies": { "isexe": "^2.0.0" }, "bin": { - "node-which": "bin/which.js" + "node-which": "bin/node-which" }, "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": ">= 8" } }, "node_modules/wide-align": { @@ -7787,6 +8938,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/widest-line/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, "node_modules/widest-line/node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -7810,6 +8973,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/widest-line/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/wildcard": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.1.tgz", @@ -7851,42 +9029,30 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "node_modules/wrap-ansi/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, "engines": { - "node": ">=8" + "node": ">=12" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/wrap-ansi/node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -7910,6 +9076,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index b128e79..6b06c62 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "1.0.0", "description": "GLTF viewer", "scripts": { + "all": "npm run update:modules && npm run format && npm run build && npm run copy:deploy && npm run dev", + "format": "prettier . --write --ignore-path .prettierignore && npx eslint ./src/** --fix", "install:ncu": "npm install -g npm-check-updates", "install:webpack": "npm install --save-dev webpack", "update:modules": "ncu -u && npm update && npm i", @@ -20,11 +22,18 @@ "devDependencies": { "@types/dat.gui": "^0.7.12", "@types/express": "^4.17.21", - "@types/node": "^20.10.4", + "@types/node": "^20.10.5", "@types/three": "^0.159.0", + "@typescript-eslint/eslint-plugin": "6.15.0", + "@typescript-eslint/parser": "6.15.0", "axios": "^1.6.2", "copyfiles": "^2.4.1", "dat.gui": "^0.7.9", + "eslint": "8.56.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-jest": "27.6.0", + "eslint-plugin-node": "11.1.0", + "eslint-plugin-prettier": "5.1.1", "install-peers": "^1.0.4", "npm-check-updates": "^16.14.12", "patch-package": "^8.0.0", @@ -39,6 +48,6 @@ "dependencies": { "express": "^4.18.2", "lodash": "^4.17.21", - "three": "0.159.0" + "three": "0.160.0" } } diff --git a/src/client/experimental/outline_pass.ts b/src/client/experimental/outline_pass.ts index 2defa2a..d62a3bf 100644 --- a/src/client/experimental/outline_pass.ts +++ b/src/client/experimental/outline_pass.ts @@ -1,490 +1,526 @@ -import { Pass, FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js'; +import { + Pass, + FullScreenQuad, +} from 'three/examples/jsm/postprocessing/Pass.js'; import { CopyShader } from 'three/examples/jsm/shaders/CopyShader.js'; +import type { + Camera, + Mesh, + Object3D, + Scene, + Texture, + WebGLRenderer, +} from 'three'; import { - AdditiveBlending, - Camera, - Color, - DoubleSide, - Matrix4, - Mesh, - MeshDepthMaterial, - NoBlending, - Object3D, - RGBADepthPacking, - Scene, - ShaderMaterial, - Texture, - UniformsUtils, - Vector2, - Vector3, - WebGLRenderer, - WebGLRenderTarget + AdditiveBlending, + Color, + DoubleSide, + Matrix4, + MeshDepthMaterial, + NoBlending, + RGBADepthPacking, + ShaderMaterial, + UniformsUtils, + Vector2, + Vector3, + WebGLRenderTarget, } from 'three'; export class OutlinePass extends Pass { - public static BlurDirectionX = new Vector2(1.0, 0.0); - public static BlurDirectionY = new Vector2(0.0, 1.0); - public renderScene: Scene; - public renderCamera: Camera; - public selectedObjects: Object3D[]; - public visibleEdgeColor: Color; - public hiddenEdgeColor: Color; - public edgeGlow: number; - public usePatternTexture: boolean; - public patternTexture: Texture | null = null; - public edgeThickness: number; - public edgeStrength: number; - public downSampleRatio: number; - public pulsePeriod: number; - public _visibilityCache: Map; - public resolution: Vector2; - public renderTargetMaskBuffer: WebGLRenderTarget; - public depthMaterial: MeshDepthMaterial; - public prepareMaskMaterial: ShaderMaterial; - public renderTargetDepthBuffer: WebGLRenderTarget; - public renderTargetMaskDownSampleBuffer: WebGLRenderTarget; - public renderTargetBlurBuffer1: WebGLRenderTarget; - public renderTargetBlurBuffer2: WebGLRenderTarget; - public edgeDetectionMaterial: ShaderMaterial; - public renderTargetEdgeBuffer1: WebGLRenderTarget; - public renderTargetEdgeBuffer2: WebGLRenderTarget; - public separableBlurMaterial1: ShaderMaterial; - public separableBlurMaterial2: ShaderMaterial; - public overlayMaterial: ShaderMaterial; - public copyUniforms: any; - public materialCopy: ShaderMaterial; - public _oldClearColor: Color; - public oldClearAlpha: number; - public fsQuad: FullScreenQuad; - public tempPulseColor1: Color; - public tempPulseColor2: Color; - public textureMatrix: Matrix4; - - constructor(resolution: Vector2, scene: Scene, camera: Camera, selectedObjects: Object3D[] ) { - - super(); - - this.renderScene = scene; - this.renderCamera = camera; - this.selectedObjects = selectedObjects !== undefined ? selectedObjects : []; - this.visibleEdgeColor = new Color( 1, 1, 1 ); - this.hiddenEdgeColor = new Color( 0.1, 0.04, 0.02 ); - this.edgeGlow = 0.0; - this.usePatternTexture = false; - this.edgeThickness = 1.0; - this.edgeStrength = 3.0; - this.downSampleRatio = 2; - this.pulsePeriod = 0; - - this._visibilityCache = new Map(); - - - this.resolution = ( resolution !== undefined ) ? new Vector2( resolution.x, resolution.y ) : new Vector2( 256, 256 ); - - const resx = Math.round( this.resolution.x / this.downSampleRatio ); - const resy = Math.round( this.resolution.y / this.downSampleRatio ); - - this.renderTargetMaskBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y ); - this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask'; - this.renderTargetMaskBuffer.texture.generateMipmaps = false; - - this.depthMaterial = new MeshDepthMaterial(); - this.depthMaterial.side = DoubleSide; - this.depthMaterial.depthPacking = RGBADepthPacking; - this.depthMaterial.blending = NoBlending; - - this.prepareMaskMaterial = this.getPrepareMaskMaterial(); - this.prepareMaskMaterial.side = DoubleSide; - this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( this.prepareMaskMaterial.fragmentShader, this.renderCamera ); - - this.renderTargetDepthBuffer = new WebGLRenderTarget( this.resolution.x, this.resolution.y ); - this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth'; - this.renderTargetDepthBuffer.texture.generateMipmaps = false; - - this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget( resx, resy ); - this.renderTargetMaskDownSampleBuffer.texture.name = 'OutlinePass.depthDownSample'; - this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false; - - this.renderTargetBlurBuffer1 = new WebGLRenderTarget( resx, resy ); - this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1'; - this.renderTargetBlurBuffer1.texture.generateMipmaps = false; - this.renderTargetBlurBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ) ); - this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2'; - this.renderTargetBlurBuffer2.texture.generateMipmaps = false; - - this.edgeDetectionMaterial = this.getEdgeDetectionMaterial(); - this.renderTargetEdgeBuffer1 = new WebGLRenderTarget( resx, resy ); - this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1'; - this.renderTargetEdgeBuffer1.texture.generateMipmaps = false; - this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( Math.round( resx / 2 ), Math.round( resy / 2 ) ); - this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2'; - this.renderTargetEdgeBuffer2.texture.generateMipmaps = false; - - const MAX_EDGE_THICKNESS = 4; - const MAX_EDGE_GLOW = 4; - - this.separableBlurMaterial1 = this.getSeperableBlurMaterial( MAX_EDGE_THICKNESS ); - this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy ); - this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = 1; - this.separableBlurMaterial2 = this.getSeperableBlurMaterial( MAX_EDGE_GLOW ); - this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( Math.round( resx / 2 ), Math.round( resy / 2 ) ); - this.separableBlurMaterial2.uniforms[ 'kernelRadius' ].value = MAX_EDGE_GLOW; - - // Overlay material - this.overlayMaterial = this.getOverlayMaterial(); - - // copy material - - const copyShader = CopyShader; - - this.copyUniforms = UniformsUtils.clone( copyShader.uniforms ); - this.copyUniforms[ 'opacity' ].value = 1.0; - - this.materialCopy = new ShaderMaterial( { - uniforms: this.copyUniforms, - vertexShader: copyShader.vertexShader, - fragmentShader: copyShader.fragmentShader, - blending: NoBlending, - depthTest: false, - depthWrite: false, - transparent: true - } ); - - this.enabled = true; - this.needsSwap = false; - - this._oldClearColor = new Color(); - this.oldClearAlpha = 1; - - this.fsQuad = new FullScreenQuad( undefined ); - - this.tempPulseColor1 = new Color(); - this.tempPulseColor2 = new Color(); - this.textureMatrix = new Matrix4(); - - function replaceDepthToViewZ( string: string, camera: Camera ) { - - // @ts-ignore - const type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic'; - - return string.replace( /DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ' ); - - } - - } - - dispose() { - - this.renderTargetMaskBuffer.dispose(); - this.renderTargetDepthBuffer.dispose(); - this.renderTargetMaskDownSampleBuffer.dispose(); - this.renderTargetBlurBuffer1.dispose(); - this.renderTargetBlurBuffer2.dispose(); - this.renderTargetEdgeBuffer1.dispose(); - this.renderTargetEdgeBuffer2.dispose(); - - this.depthMaterial.dispose(); - this.prepareMaskMaterial.dispose(); - this.edgeDetectionMaterial.dispose(); - this.separableBlurMaterial1.dispose(); - this.separableBlurMaterial2.dispose(); - this.overlayMaterial.dispose(); - this.materialCopy.dispose(); - - this.fsQuad.dispose(); - - } - - setSize(width: number, height: number) { - - this.renderTargetMaskBuffer.setSize( width, height ); - this.renderTargetDepthBuffer.setSize( width, height ); - - let resx = Math.round( width / this.downSampleRatio ); - let resy = Math.round( height / this.downSampleRatio ); - this.renderTargetMaskDownSampleBuffer.setSize( resx, resy ); - this.renderTargetBlurBuffer1.setSize( resx, resy ); - this.renderTargetEdgeBuffer1.setSize( resx, resy ); - this.separableBlurMaterial1.uniforms[ 'texSize' ].value.set( resx, resy ); - - resx = Math.round( resx / 2 ); - resy = Math.round( resy / 2 ); - - this.renderTargetBlurBuffer2.setSize( resx, resy ); - this.renderTargetEdgeBuffer2.setSize( resx, resy ); - - this.separableBlurMaterial2.uniforms[ 'texSize' ].value.set( resx, resy ); - - } - - changeVisibilityOfSelectedObjects(bVisible: boolean) { - - const cache = this._visibilityCache; - - function gatherSelectedMeshesCallBack(object: Object3D) { - - // @ts-ignore - if ( object.isMesh ) { - - if ( bVisible === true ) { - // @ts-ignore - object.visible = cache.get( object ); - - } else { - cache.set( object, object.visible ); - object.visible = bVisible; - } - } - } - - for ( let i = 0; i < this.selectedObjects.length; i ++ ) { - - const selectedObject = this.selectedObjects[ i ]; - selectedObject.traverse( gatherSelectedMeshesCallBack ); - - } - - } - - changeVisibilityOfNonSelectedObjects(bVisible: boolean) { - - const cache = this._visibilityCache; - const selectedMeshes: Mesh[] = []; - - function gatherSelectedMeshesCallBack(object: Object3D ) { - // @ts-ignore - if ( object.isMesh ) selectedMeshes.push( object ); - } - - for ( let i = 0; i < this.selectedObjects.length; i ++ ) { - - const selectedObject = this.selectedObjects[ i ]; - selectedObject.traverse( gatherSelectedMeshesCallBack ); - - } - - function VisibilityChangeCallBack(object: Object3D) { - // @ts-ignore - if ( object.isMesh || object.isSprite ) { - - // only meshes and sprites are supported by OutlinePass - - let bFound = false; - - for ( let i = 0; i < selectedMeshes.length; i ++ ) { - - const selectedObjectId = selectedMeshes[ i ].id; - - if ( selectedObjectId === object.id ) { - - bFound = true; - break; - - } - - } - - if ( bFound === false ) { - - const visibility = object.visible; - - if ( bVisible === false || cache.get( object ) === true ) { - - object.visible = bVisible; - - } - - cache.set( object, visibility ); - - } - - // @ts-ignore - } else if ( object.isPoints || object.isLine ) { - - // the visibilty of points and lines is always set to false in order to - // not affect the outline computation - - if ( bVisible === true ) { - // @ts-ignore - object.visible = cache.get( object ); // restore - - } else { - - cache.set( object, object.visible ); - object.visible = bVisible; - - } - - } - - } - - this.renderScene.traverse( VisibilityChangeCallBack ); - - } - - updateTextureMatrix() { - - this.textureMatrix.set( 0.5, 0.0, 0.0, 0.5, - 0.0, 0.5, 0.0, 0.5, - 0.0, 0.0, 0.5, 0.5, - 0.0, 0.0, 0.0, 1.0 ); - this.textureMatrix.multiply( this.renderCamera.projectionMatrix ); - this.textureMatrix.multiply( this.renderCamera.matrixWorldInverse ); - - } - - render(renderer: WebGLRenderer, - _writeBuffer: WebGLRenderTarget | null, - readBuffer: WebGLRenderTarget | null, - _deltaTime: number, - maskActive: boolean) { - - if ( this.selectedObjects.length > 0 ) { - - renderer.getClearColor( this._oldClearColor ); - this.oldClearAlpha = renderer.getClearAlpha(); - const oldAutoClear = renderer.autoClear; - - renderer.autoClear = false; - - if ( maskActive ) renderer.state.buffers.stencil.setTest( false ); - - renderer.setClearColor( 0xffffff, 1 ); - - // Make selected objects invisible - this.changeVisibilityOfSelectedObjects( false ); - - const currentBackground = this.renderScene.background; - this.renderScene.background = null; - - // 1. Draw Non Selected objects in the depth buffer - this.renderScene.overrideMaterial = this.depthMaterial; - renderer.setRenderTarget( this.renderTargetDepthBuffer ); - renderer.clear(); - renderer.render( this.renderScene, this.renderCamera ); - - // Make selected objects visible - this.changeVisibilityOfSelectedObjects( true ); - this._visibilityCache.clear(); - - // Update Texture Matrix for Depth compare - this.updateTextureMatrix(); - - // Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects - this.changeVisibilityOfNonSelectedObjects( false ); - this.renderScene.overrideMaterial = this.prepareMaskMaterial; - // @ts-ignore - this.prepareMaskMaterial.uniforms[ 'cameraNearFar' ].value.set( this.renderCamera.near, this.renderCamera.far ); - this.prepareMaskMaterial.uniforms[ 'depthTexture' ].value = this.renderTargetDepthBuffer.texture; - this.prepareMaskMaterial.uniforms[ 'textureMatrix' ].value = this.textureMatrix; - renderer.setRenderTarget( this.renderTargetMaskBuffer ); - renderer.clear(); - renderer.render( this.renderScene, this.renderCamera ); - this.renderScene.overrideMaterial = null; - this.changeVisibilityOfNonSelectedObjects( true ); - this._visibilityCache.clear(); - - this.renderScene.background = currentBackground; - - // 2. Downsample to Half resolution - this.fsQuad.material = this.materialCopy; - this.copyUniforms[ 'tDiffuse' ].value = this.renderTargetMaskBuffer.texture; - renderer.setRenderTarget( this.renderTargetMaskDownSampleBuffer ); - renderer.clear(); - this.fsQuad.render( renderer ); - - this.tempPulseColor1.copy( this.visibleEdgeColor ); - this.tempPulseColor2.copy( this.hiddenEdgeColor ); - - if ( this.pulsePeriod > 0 ) { - - const scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01 / this.pulsePeriod ) * ( 1.0 - 0.25 ) / 2; - this.tempPulseColor1.multiplyScalar( scalar ); - this.tempPulseColor2.multiplyScalar( scalar ); - - } - - // 3. Apply Edge Detection Pass - this.fsQuad.material = this.edgeDetectionMaterial; - this.edgeDetectionMaterial.uniforms[ 'maskTexture' ].value = this.renderTargetMaskDownSampleBuffer.texture; - this.edgeDetectionMaterial.uniforms[ 'texSize' ].value.set( this.renderTargetMaskDownSampleBuffer.width, this.renderTargetMaskDownSampleBuffer.height ); - this.edgeDetectionMaterial.uniforms[ 'visibleEdgeColor' ].value = this.tempPulseColor1; - this.edgeDetectionMaterial.uniforms[ 'hiddenEdgeColor' ].value = this.tempPulseColor2; - renderer.setRenderTarget( this.renderTargetEdgeBuffer1 ); - renderer.clear(); - this.fsQuad.render( renderer ); - - // 4. Apply Blur on Half res - this.fsQuad.material = this.separableBlurMaterial1; - this.separableBlurMaterial1.uniforms[ 'colorTexture' ].value = this.renderTargetEdgeBuffer1.texture; - this.separableBlurMaterial1.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionX; - this.separableBlurMaterial1.uniforms[ 'kernelRadius' ].value = this.edgeThickness; - renderer.setRenderTarget( this.renderTargetBlurBuffer1 ); - renderer.clear(); - this.fsQuad.render( renderer ); - this.separableBlurMaterial1.uniforms[ 'colorTexture' ].value = this.renderTargetBlurBuffer1.texture; - this.separableBlurMaterial1.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionY; - renderer.setRenderTarget( this.renderTargetEdgeBuffer1 ); - renderer.clear(); - this.fsQuad.render( renderer ); - - // Apply Blur on quarter res - this.fsQuad.material = this.separableBlurMaterial2; - this.separableBlurMaterial2.uniforms[ 'colorTexture' ].value = this.renderTargetEdgeBuffer1.texture; - this.separableBlurMaterial2.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionX; - renderer.setRenderTarget( this.renderTargetBlurBuffer2 ); - renderer.clear(); - this.fsQuad.render( renderer ); - this.separableBlurMaterial2.uniforms[ 'colorTexture' ].value = this.renderTargetBlurBuffer2.texture; - this.separableBlurMaterial2.uniforms[ 'direction' ].value = OutlinePass.BlurDirectionY; - renderer.setRenderTarget( this.renderTargetEdgeBuffer2 ); - renderer.clear(); - this.fsQuad.render( renderer ); - - // Blend it additively over the input texture - this.fsQuad.material = this.overlayMaterial; - this.overlayMaterial.uniforms[ 'maskTexture' ].value = this.renderTargetMaskBuffer.texture; - this.overlayMaterial.uniforms[ 'edgeTexture1' ].value = this.renderTargetEdgeBuffer1.texture; - this.overlayMaterial.uniforms[ 'edgeTexture2' ].value = this.renderTargetEdgeBuffer2.texture; - this.overlayMaterial.uniforms[ 'patternTexture' ].value = this.patternTexture; - this.overlayMaterial.uniforms[ 'edgeStrength' ].value = this.edgeStrength; - this.overlayMaterial.uniforms[ 'edgeGlow' ].value = this.edgeGlow; - this.overlayMaterial.uniforms[ 'usePatternTexture' ].value = this.usePatternTexture; - - - if ( maskActive ) renderer.state.buffers.stencil.setTest( true ); - - renderer.setRenderTarget( readBuffer ); - this.fsQuad.render( renderer ); - - renderer.setClearColor( this._oldClearColor, this.oldClearAlpha ); - renderer.autoClear = oldAutoClear; - - } - - if (this.renderToScreen && readBuffer) { - - this.fsQuad.material = this.materialCopy; - this.copyUniforms[ 'tDiffuse' ].value = readBuffer.texture; - renderer.setRenderTarget( null ); - this.fsQuad.render( renderer ); - - } - } - - getPrepareMaskMaterial() { - - return new ShaderMaterial( { - - uniforms: { - 'depthTexture': { value: null }, - 'cameraNearFar': { value: new Vector2( 0.5, 0.5 ) }, - 'textureMatrix': { value: null } - }, - - vertexShader: - `#include + public static BlurDirectionX = new Vector2(1.0, 0.0); + public static BlurDirectionY = new Vector2(0.0, 1.0); + public renderScene: Scene; + public renderCamera: Camera; + public selectedObjects: Object3D[]; + public visibleEdgeColor: Color; + public hiddenEdgeColor: Color; + public edgeGlow: number; + public usePatternTexture: boolean; + public patternTexture: Texture | null = null; + public edgeThickness: number; + public edgeStrength: number; + public downSampleRatio: number; + public pulsePeriod: number; + public _visibilityCache: Map; + public resolution: Vector2; + public renderTargetMaskBuffer: WebGLRenderTarget; + public depthMaterial: MeshDepthMaterial; + public prepareMaskMaterial: ShaderMaterial; + public renderTargetDepthBuffer: WebGLRenderTarget; + public renderTargetMaskDownSampleBuffer: WebGLRenderTarget; + public renderTargetBlurBuffer1: WebGLRenderTarget; + public renderTargetBlurBuffer2: WebGLRenderTarget; + public edgeDetectionMaterial: ShaderMaterial; + public renderTargetEdgeBuffer1: WebGLRenderTarget; + public renderTargetEdgeBuffer2: WebGLRenderTarget; + public separableBlurMaterial1: ShaderMaterial; + public separableBlurMaterial2: ShaderMaterial; + public overlayMaterial: ShaderMaterial; + public copyUniforms: any; + public materialCopy: ShaderMaterial; + public _oldClearColor: Color; + public oldClearAlpha: number; + public fsQuad: FullScreenQuad; + public tempPulseColor1: Color; + public tempPulseColor2: Color; + public textureMatrix: Matrix4; + + constructor( + resolution: Vector2, + scene: Scene, + camera: Camera, + selectedObjects: Object3D[] + ) { + super(); + + this.renderScene = scene; + this.renderCamera = camera; + this.selectedObjects = selectedObjects !== undefined ? selectedObjects : []; + this.visibleEdgeColor = new Color(1, 1, 1); + this.hiddenEdgeColor = new Color(0.1, 0.04, 0.02); + this.edgeGlow = 0.0; + this.usePatternTexture = false; + this.edgeThickness = 1.0; + this.edgeStrength = 3.0; + this.downSampleRatio = 2; + this.pulsePeriod = 0; + + this._visibilityCache = new Map(); + + this.resolution = + resolution !== undefined + ? new Vector2(resolution.x, resolution.y) + : new Vector2(256, 256); + + const resx = Math.round(this.resolution.x / this.downSampleRatio); + const resy = Math.round(this.resolution.y / this.downSampleRatio); + + this.renderTargetMaskBuffer = new WebGLRenderTarget( + this.resolution.x, + this.resolution.y + ); + this.renderTargetMaskBuffer.texture.name = 'OutlinePass.mask'; + this.renderTargetMaskBuffer.texture.generateMipmaps = false; + + this.depthMaterial = new MeshDepthMaterial(); + this.depthMaterial.side = DoubleSide; + this.depthMaterial.depthPacking = RGBADepthPacking; + this.depthMaterial.blending = NoBlending; + + this.prepareMaskMaterial = this.getPrepareMaskMaterial(); + this.prepareMaskMaterial.side = DoubleSide; + this.prepareMaskMaterial.fragmentShader = replaceDepthToViewZ( + this.prepareMaskMaterial.fragmentShader, + this.renderCamera + ); + + this.renderTargetDepthBuffer = new WebGLRenderTarget( + this.resolution.x, + this.resolution.y + ); + this.renderTargetDepthBuffer.texture.name = 'OutlinePass.depth'; + this.renderTargetDepthBuffer.texture.generateMipmaps = false; + + this.renderTargetMaskDownSampleBuffer = new WebGLRenderTarget(resx, resy); + this.renderTargetMaskDownSampleBuffer.texture.name = + 'OutlinePass.depthDownSample'; + this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps = false; + + this.renderTargetBlurBuffer1 = new WebGLRenderTarget(resx, resy); + this.renderTargetBlurBuffer1.texture.name = 'OutlinePass.blur1'; + this.renderTargetBlurBuffer1.texture.generateMipmaps = false; + this.renderTargetBlurBuffer2 = new WebGLRenderTarget( + Math.round(resx / 2), + Math.round(resy / 2) + ); + this.renderTargetBlurBuffer2.texture.name = 'OutlinePass.blur2'; + this.renderTargetBlurBuffer2.texture.generateMipmaps = false; + + this.edgeDetectionMaterial = this.getEdgeDetectionMaterial(); + this.renderTargetEdgeBuffer1 = new WebGLRenderTarget(resx, resy); + this.renderTargetEdgeBuffer1.texture.name = 'OutlinePass.edge1'; + this.renderTargetEdgeBuffer1.texture.generateMipmaps = false; + this.renderTargetEdgeBuffer2 = new WebGLRenderTarget( + Math.round(resx / 2), + Math.round(resy / 2) + ); + this.renderTargetEdgeBuffer2.texture.name = 'OutlinePass.edge2'; + this.renderTargetEdgeBuffer2.texture.generateMipmaps = false; + + const MAX_EDGE_THICKNESS = 4; + const MAX_EDGE_GLOW = 4; + + this.separableBlurMaterial1 = + this.getSeperableBlurMaterial(MAX_EDGE_THICKNESS); + this.separableBlurMaterial1.uniforms.texSize.value.set(resx, resy); + this.separableBlurMaterial1.uniforms.kernelRadius.value = 1; + this.separableBlurMaterial2 = this.getSeperableBlurMaterial(MAX_EDGE_GLOW); + this.separableBlurMaterial2.uniforms.texSize.value.set( + Math.round(resx / 2), + Math.round(resy / 2) + ); + this.separableBlurMaterial2.uniforms.kernelRadius.value = MAX_EDGE_GLOW; + + // Overlay material + this.overlayMaterial = this.getOverlayMaterial(); + + // copy material + + const copyShader = CopyShader; + + this.copyUniforms = UniformsUtils.clone(copyShader.uniforms); + this.copyUniforms.opacity.value = 1.0; + + this.materialCopy = new ShaderMaterial({ + uniforms: this.copyUniforms, + vertexShader: copyShader.vertexShader, + fragmentShader: copyShader.fragmentShader, + blending: NoBlending, + depthTest: false, + depthWrite: false, + transparent: true, + }); + + this.enabled = true; + this.needsSwap = false; + + this._oldClearColor = new Color(); + this.oldClearAlpha = 1; + + this.fsQuad = new FullScreenQuad(undefined); + + this.tempPulseColor1 = new Color(); + this.tempPulseColor2 = new Color(); + this.textureMatrix = new Matrix4(); + + function replaceDepthToViewZ(string: string, _camera: Camera) { + // @ts-ignore + const type = camera.isPerspectiveCamera ? 'perspective' : 'orthographic'; + return string.replace(/DEPTH_TO_VIEW_Z/g, type + 'DepthToViewZ'); + } + } + + dispose() { + this.renderTargetMaskBuffer.dispose(); + this.renderTargetDepthBuffer.dispose(); + this.renderTargetMaskDownSampleBuffer.dispose(); + this.renderTargetBlurBuffer1.dispose(); + this.renderTargetBlurBuffer2.dispose(); + this.renderTargetEdgeBuffer1.dispose(); + this.renderTargetEdgeBuffer2.dispose(); + + this.depthMaterial.dispose(); + this.prepareMaskMaterial.dispose(); + this.edgeDetectionMaterial.dispose(); + this.separableBlurMaterial1.dispose(); + this.separableBlurMaterial2.dispose(); + this.overlayMaterial.dispose(); + this.materialCopy.dispose(); + + this.fsQuad.dispose(); + } + + setSize(width: number, height: number) { + this.renderTargetMaskBuffer.setSize(width, height); + this.renderTargetDepthBuffer.setSize(width, height); + + let resx = Math.round(width / this.downSampleRatio); + let resy = Math.round(height / this.downSampleRatio); + this.renderTargetMaskDownSampleBuffer.setSize(resx, resy); + this.renderTargetBlurBuffer1.setSize(resx, resy); + this.renderTargetEdgeBuffer1.setSize(resx, resy); + this.separableBlurMaterial1.uniforms.texSize.value.set(resx, resy); + + resx = Math.round(resx / 2); + resy = Math.round(resy / 2); + + this.renderTargetBlurBuffer2.setSize(resx, resy); + this.renderTargetEdgeBuffer2.setSize(resx, resy); + + this.separableBlurMaterial2.uniforms.texSize.value.set(resx, resy); + } + + changeVisibilityOfSelectedObjects(bVisible: boolean) { + const cache = this._visibilityCache; + + function gatherSelectedMeshesCallBack(object: Object3D) { + // @ts-ignore + if (object.isMesh) { + if (bVisible === true) { + // @ts-ignore + object.visible = cache.get(object); + } else { + cache.set(object, object.visible); + object.visible = bVisible; + } + } + } + + for (let i = 0; i < this.selectedObjects.length; i++) { + const selectedObject = this.selectedObjects[i]; + selectedObject.traverse(gatherSelectedMeshesCallBack); + } + } + + changeVisibilityOfNonSelectedObjects(bVisible: boolean) { + const cache = this._visibilityCache; + const selectedMeshes: Mesh[] = []; + + function gatherSelectedMeshesCallBack(object: Object3D) { + // @ts-ignore + if (object.isMesh) { + // @ts-ignore + selectedMeshes.push(object); + } + } + + for (let i = 0; i < this.selectedObjects.length; i++) { + const selectedObject = this.selectedObjects[i]; + selectedObject.traverse(gatherSelectedMeshesCallBack); + } + + function VisibilityChangeCallBack(object: Object3D) { + // @ts-ignore + if (object.isMesh || object.isSprite) { + // only meshes and sprites are supported by OutlinePass + + let bFound = false; + + for (let i = 0; i < selectedMeshes.length; i++) { + const selectedObjectId = selectedMeshes[i].id; + + if (selectedObjectId === object.id) { + bFound = true; + break; + } + } + + if (bFound === false) { + const visibility = object.visible; + + if (bVisible === false || cache.get(object) === true) { + object.visible = bVisible; + } + + cache.set(object, visibility); + } + + // @ts-ignore + } else if (object.isPoints || object.isLine) { + // the visibilty of points and lines is always set to false in order to + // not affect the outline computation + + if (bVisible === true) { + // @ts-ignore + object.visible = cache.get(object); // restore + } else { + cache.set(object, object.visible); + object.visible = bVisible; + } + } + } + + this.renderScene.traverse(VisibilityChangeCallBack); + } + + updateTextureMatrix() { + this.textureMatrix.set( + 0.5, + 0.0, + 0.0, + 0.5, + 0.0, + 0.5, + 0.0, + 0.5, + 0.0, + 0.0, + 0.5, + 0.5, + 0.0, + 0.0, + 0.0, + 1.0 + ); + this.textureMatrix.multiply(this.renderCamera.projectionMatrix); + this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse); + } + + render( + renderer: WebGLRenderer, + _writeBuffer: WebGLRenderTarget | null, + readBuffer: WebGLRenderTarget | null, + _deltaTime: number, + maskActive: boolean + ) { + if (this.selectedObjects.length > 0) { + renderer.getClearColor(this._oldClearColor); + this.oldClearAlpha = renderer.getClearAlpha(); + const oldAutoClear = renderer.autoClear; + + renderer.autoClear = false; + + if (maskActive) { + renderer.state.buffers.stencil.setTest(false); + } + + renderer.setClearColor(0xffffff, 1); + + // Make selected objects invisible + this.changeVisibilityOfSelectedObjects(false); + + const currentBackground = this.renderScene.background; + this.renderScene.background = null; + + // 1. Draw Non Selected objects in the depth buffer + this.renderScene.overrideMaterial = this.depthMaterial; + renderer.setRenderTarget(this.renderTargetDepthBuffer); + renderer.clear(); + renderer.render(this.renderScene, this.renderCamera); + + // Make selected objects visible + this.changeVisibilityOfSelectedObjects(true); + this._visibilityCache.clear(); + + // Update Texture Matrix for Depth compare + this.updateTextureMatrix(); + + // Make non selected objects invisible, and draw only the selected objects, by comparing the depth buffer of non selected objects + this.changeVisibilityOfNonSelectedObjects(false); + this.renderScene.overrideMaterial = this.prepareMaskMaterial; + this.prepareMaskMaterial.uniforms.cameraNearFar.value.set( + // @ts-ignore + this.renderCamera.near, + // @ts-ignore + this.renderCamera.far + ); + this.prepareMaskMaterial.uniforms.depthTexture.value = + this.renderTargetDepthBuffer.texture; + this.prepareMaskMaterial.uniforms.textureMatrix.value = + this.textureMatrix; + renderer.setRenderTarget(this.renderTargetMaskBuffer); + renderer.clear(); + renderer.render(this.renderScene, this.renderCamera); + this.renderScene.overrideMaterial = null; + this.changeVisibilityOfNonSelectedObjects(true); + this._visibilityCache.clear(); + + this.renderScene.background = currentBackground; + + // 2. Downsample to Half resolution + this.fsQuad.material = this.materialCopy; + this.copyUniforms.tDiffuse.value = this.renderTargetMaskBuffer.texture; + renderer.setRenderTarget(this.renderTargetMaskDownSampleBuffer); + renderer.clear(); + this.fsQuad.render(renderer); + + this.tempPulseColor1.copy(this.visibleEdgeColor); + this.tempPulseColor2.copy(this.hiddenEdgeColor); + + if (this.pulsePeriod > 0) { + const scalar = + (1 + 0.25) / 2 + + (Math.cos((performance.now() * 0.01) / this.pulsePeriod) * + (1.0 - 0.25)) / + 2; + this.tempPulseColor1.multiplyScalar(scalar); + this.tempPulseColor2.multiplyScalar(scalar); + } + + // 3. Apply Edge Detection Pass + this.fsQuad.material = this.edgeDetectionMaterial; + this.edgeDetectionMaterial.uniforms.maskTexture.value = + this.renderTargetMaskDownSampleBuffer.texture; + this.edgeDetectionMaterial.uniforms.texSize.value.set( + this.renderTargetMaskDownSampleBuffer.width, + this.renderTargetMaskDownSampleBuffer.height + ); + this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value = + this.tempPulseColor1; + this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value = + this.tempPulseColor2; + renderer.setRenderTarget(this.renderTargetEdgeBuffer1); + renderer.clear(); + this.fsQuad.render(renderer); + + // 4. Apply Blur on Half res + this.fsQuad.material = this.separableBlurMaterial1; + this.separableBlurMaterial1.uniforms.colorTexture.value = + this.renderTargetEdgeBuffer1.texture; + this.separableBlurMaterial1.uniforms.direction.value = + OutlinePass.BlurDirectionX; + this.separableBlurMaterial1.uniforms.kernelRadius.value = + this.edgeThickness; + renderer.setRenderTarget(this.renderTargetBlurBuffer1); + renderer.clear(); + this.fsQuad.render(renderer); + this.separableBlurMaterial1.uniforms.colorTexture.value = + this.renderTargetBlurBuffer1.texture; + this.separableBlurMaterial1.uniforms.direction.value = + OutlinePass.BlurDirectionY; + renderer.setRenderTarget(this.renderTargetEdgeBuffer1); + renderer.clear(); + this.fsQuad.render(renderer); + + // Apply Blur on quarter res + this.fsQuad.material = this.separableBlurMaterial2; + this.separableBlurMaterial2.uniforms.colorTexture.value = + this.renderTargetEdgeBuffer1.texture; + this.separableBlurMaterial2.uniforms.direction.value = + OutlinePass.BlurDirectionX; + renderer.setRenderTarget(this.renderTargetBlurBuffer2); + renderer.clear(); + this.fsQuad.render(renderer); + this.separableBlurMaterial2.uniforms.colorTexture.value = + this.renderTargetBlurBuffer2.texture; + this.separableBlurMaterial2.uniforms.direction.value = + OutlinePass.BlurDirectionY; + renderer.setRenderTarget(this.renderTargetEdgeBuffer2); + renderer.clear(); + this.fsQuad.render(renderer); + + // Blend it additively over the input texture + this.fsQuad.material = this.overlayMaterial; + this.overlayMaterial.uniforms.maskTexture.value = + this.renderTargetMaskBuffer.texture; + this.overlayMaterial.uniforms.edgeTexture1.value = + this.renderTargetEdgeBuffer1.texture; + this.overlayMaterial.uniforms.edgeTexture2.value = + this.renderTargetEdgeBuffer2.texture; + this.overlayMaterial.uniforms.patternTexture.value = this.patternTexture; + this.overlayMaterial.uniforms.edgeStrength.value = this.edgeStrength; + this.overlayMaterial.uniforms.edgeGlow.value = this.edgeGlow; + this.overlayMaterial.uniforms.usePatternTexture.value = + this.usePatternTexture; + + if (maskActive) { + renderer.state.buffers.stencil.setTest(true); + } + + renderer.setRenderTarget(readBuffer); + this.fsQuad.render(renderer); + + renderer.setClearColor(this._oldClearColor, this.oldClearAlpha); + renderer.autoClear = oldAutoClear; + } + + if (this.renderToScreen && readBuffer) { + this.fsQuad.material = this.materialCopy; + this.copyUniforms.tDiffuse.value = readBuffer.texture; + renderer.setRenderTarget(null); + this.fsQuad.render(renderer); + } + } + + getPrepareMaskMaterial() { + return new ShaderMaterial({ + uniforms: { + depthTexture: { value: null }, + cameraNearFar: { value: new Vector2(0.5, 0.5) }, + textureMatrix: { value: null }, + }, + + vertexShader: `#include #include varying vec4 projTexCoord; @@ -515,8 +551,7 @@ export class OutlinePass extends Pass { }`, - fragmentShader: - `#include + fragmentShader: `#include varying vec4 vPosition; varying vec4 projTexCoord; uniform sampler2D depthTexture; @@ -529,33 +564,27 @@ export class OutlinePass extends Pass { float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0; gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0); - }` - - } ); - - } - - getEdgeDetectionMaterial() { - - return new ShaderMaterial( { + }`, + }); + } - uniforms: { - 'maskTexture': { value: null }, - 'texSize': { value: new Vector2( 0.5, 0.5 ) }, - 'visibleEdgeColor': { value: new Vector3( 1.0, 1.0, 1.0 ) }, - 'hiddenEdgeColor': { value: new Vector3( 1.0, 1.0, 1.0 ) }, - }, + getEdgeDetectionMaterial() { + return new ShaderMaterial({ + uniforms: { + maskTexture: { value: null }, + texSize: { value: new Vector2(0.5, 0.5) }, + visibleEdgeColor: { value: new Vector3(1.0, 1.0, 1.0) }, + hiddenEdgeColor: { value: new Vector3(1.0, 1.0, 1.0) }, + }, - vertexShader: - `varying vec2 vUv; + vertexShader: `varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`, - fragmentShader: - `varying vec2 vUv; + fragmentShader: `varying vec2 vUv; uniform sampler2D maskTexture; uniform vec2 texSize; @@ -577,36 +606,31 @@ export class OutlinePass extends Pass { float visibilityFactor = min(a1, a2); vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor; gl_FragColor = vec4(edgeColor, 1.0) * vec4(d); - }` - } ); - - } - - getSeperableBlurMaterial(maxRadius: number) { - - return new ShaderMaterial( { + }`, + }); + } - defines: { - 'MAX_RADIUS': maxRadius, - }, + getSeperableBlurMaterial(maxRadius: number) { + return new ShaderMaterial({ + defines: { + MAX_RADIUS: maxRadius, + }, - uniforms: { - 'colorTexture': { value: null }, - 'texSize': { value: new Vector2( 0.5, 0.5 ) }, - 'direction': { value: new Vector2( 0.5, 0.5 ) }, - 'kernelRadius': { value: 1.0 } - }, + uniforms: { + colorTexture: { value: null }, + texSize: { value: new Vector2(0.5, 0.5) }, + direction: { value: new Vector2(0.5, 0.5) }, + kernelRadius: { value: 1.0 }, + }, - vertexShader: - `varying vec2 vUv; + vertexShader: `varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`, - fragmentShader: - `#include + fragmentShader: `#include varying vec2 vUv; uniform sampler2D colorTexture; uniform vec2 texSize; @@ -634,35 +658,30 @@ export class OutlinePass extends Pass { uvOffset += delta; } gl_FragColor = diffuseSum/weightSum; - }` - } ); - - } - - getOverlayMaterial() { - - return new ShaderMaterial( { - - uniforms: { - 'maskTexture': { value: null }, - 'edgeTexture1': { value: null }, - 'edgeTexture2': { value: null }, - 'patternTexture': { value: null }, - 'edgeStrength': { value: 1.0 }, - 'edgeGlow': { value: 1.0 }, - 'usePatternTexture': { value: 0.0 } - }, - - vertexShader: - `varying vec2 vUv; + }`, + }); + } + + getOverlayMaterial() { + return new ShaderMaterial({ + uniforms: { + maskTexture: { value: null }, + edgeTexture1: { value: null }, + edgeTexture2: { value: null }, + patternTexture: { value: null }, + edgeStrength: { value: 1.0 }, + edgeGlow: { value: 1.0 }, + usePatternTexture: { value: 0.0 }, + }, + + vertexShader: `varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`, - fragmentShader: - `varying vec2 vUv; + fragmentShader: `varying vec2 vUv; uniform sampler2D maskTexture; uniform sampler2D edgeTexture1; @@ -684,13 +703,10 @@ export class OutlinePass extends Pass { finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r); gl_FragColor = finalColor; }`, - blending: AdditiveBlending, - depthTest: false, - depthWrite: false, - transparent: true - } ); - - } - + blending: AdditiveBlending, + depthTest: false, + depthWrite: false, + transparent: true, + }); + } } - diff --git a/src/client/glbMap.ts b/src/client/glbMap.ts index 4b2ecf0..d716669 100644 --- a/src/client/glbMap.ts +++ b/src/client/glbMap.ts @@ -1,4 +1,4 @@ export const glbMap: any = [ - { name: 'BrainStem', url: './BrainStem.glb' }, - { name: 'DamagedHelmet', url: './DamagedHelmet.glb' }, + { name: 'BrainStem', url: './BrainStem.glb' }, + { name: 'DamagedHelmet', url: './DamagedHelmet.glb' }, ]; diff --git a/src/client/loader/environment_map/environemtMapReader.ts b/src/client/loader/environment_map/environemtMapReader.ts index a6909f2..37b4c46 100644 --- a/src/client/loader/environment_map/environemtMapReader.ts +++ b/src/client/loader/environment_map/environemtMapReader.ts @@ -1,148 +1,153 @@ +import type { ColorSpace, TextureDataType } from 'three'; import { - ColorSpace, - CubeTexture, - DataTexture, - FileLoader, - LinearSRGBColorSpace, - LinearFilter, - LinearMipMapLinearFilter, - RGBAFormat, - TextureDataType, - UnsignedByteType, - Vector3, - SRGBColorSpace + CubeTexture, + DataTexture, + FileLoader, + LinearSRGBColorSpace, + LinearFilter, + LinearMipMapLinearFilter, + RGBAFormat, + UnsignedByteType, + Vector3, + SRGBColorSpace, } from 'three'; const _HEADER_BYTES_ = 30; export class EnvMapReader { - private _cubeTextures: any[]; - private _lightDirection: any; - private _size: number = 256; - private _maxLod: number = 0; - private _colorSpace: ColorSpace = SRGBColorSpace; - private _type: number = UnsignedByteType; - private _format: number = RGBAFormat; - private _cubeTexture: any; - private _path: string; - - constructor() { - this._cubeTextures = []; - this._lightDirection = new Vector3(); - this._path = ''; - } - - public setPath(path: string) { - this._path = path; - } - - public load(fileName: string) { - return new Promise((resolve) => { - new FileLoader() - .setResponseType('arraybuffer') - .load(this._path + fileName, (buffer: any) => { - this.parseData_(buffer); - resolve(this._cubeTexture); - }); + private _cubeTextures: any[]; + private _lightDirection: any; + private _size: number = 256; + private _maxLod: number = 0; + private _colorSpace: ColorSpace = SRGBColorSpace; + private _type: number = UnsignedByteType; + private _format: number = RGBAFormat; + private _cubeTexture: any; + private _path: string; + + constructor() { + this._cubeTextures = []; + this._lightDirection = new Vector3(); + this._path = ''; + } + + public setPath(path: string) { + this._path = path; + } + + public load(fileName: string) { + return new Promise((resolve) => { + new FileLoader() + .setResponseType('arraybuffer') + .load(this._path + fileName, (buffer: any) => { + this.parseData_(buffer); + resolve(this._cubeTexture); }); + }); + } + + private parseHeader_(buffer: ArrayBuffer) { + const view = new DataView(buffer, 0, _HEADER_BYTES_); + this._size = view.getUint16(0); + this._maxLod = view.getUint8(2); + this._colorSpace = view.getUint16(3) + ? LinearSRGBColorSpace + : SRGBColorSpace; + this._type = view.getUint16(5); + this._format = view.getUint16(7); + this._lightDirection.x = view.getFloat32(9); + this._lightDirection.y = view.getFloat32(13); + this._lightDirection.z = view.getFloat32(17); + } + + private parseBufferData_(buffer: ArrayBuffer, offsetBytes: number) { + let size = this._size; + const cpp = 4; + const numMips = Math.log2(this._size) + 1; + this._cubeTextures = []; + + for (let i = 0; i < numMips; i++) { + const cubeTexture = new CubeTexture(); + this._cubeTextures.push(cubeTexture); + cubeTexture.format = RGBAFormat; + cubeTexture.colorSpace = this._colorSpace; + cubeTexture.type = this._type as TextureDataType; + cubeTexture.minFilter = LinearMipMapLinearFilter; + cubeTexture.magFilter = LinearFilter; + cubeTexture.generateMipmaps = false; + + for (let j = 0; j < 6; j++) { + const view = new Uint8Array(buffer, offsetBytes, cpp * size * size); + const dataTexture = new DataTexture(view, size, size); + dataTexture.format = cubeTexture.format; + dataTexture.colorSpace = cubeTexture.colorSpace; + dataTexture.type = cubeTexture.type; + dataTexture.generateMipmaps = false; + + offsetBytes += cpp * size * size; + cubeTexture.images[j] = dataTexture; + dataTexture.needsUpdate = true; + } + + cubeTexture.needsUpdate = true; + size /= 2; } - private parseHeader_(buffer: ArrayBuffer) { - let view = new DataView(buffer, 0, _HEADER_BYTES_); - this._size = view.getUint16(0); - this._maxLod = view.getUint8(2); - this._colorSpace = view.getUint16(3) ? LinearSRGBColorSpace : SRGBColorSpace; - this._type = view.getUint16(5); - this._format = view.getUint16(7); - this._lightDirection.x = view.getFloat32(9); - this._lightDirection.y = view.getFloat32(13); - this._lightDirection.z = view.getFloat32(17); + this._cubeTexture = new CubeTexture(); + this._cubeTexture.format = RGBAFormat; + this._cubeTexture.colorSpace = this._colorSpace; + this._cubeTexture.type = this._type; + this._cubeTexture.minFilter = LinearMipMapLinearFilter; + this._cubeTexture.magFilter = LinearFilter; + this._cubeTexture.generateMipmaps = false; + + for (let i = 0; i < 6; i++) { + this._cubeTexture.image[i] = this._cubeTextures[0].images[i]; + for (let m = 1; m < numMips; m++) { + this._cubeTexture.mipmaps[m - 1] = this._cubeTextures[m]; + this._cubeTextures[m].needsUpdate = true; + } } - - private parseBufferData_(buffer: ArrayBuffer, offsetBytes: number) { - let size = this._size; - let cpp = 4; - const numMips = Math.log2(this._size) + 1; - this._cubeTextures = []; - - for (let i = 0; i < numMips; i++) { - let cubeTexture = new CubeTexture(); - this._cubeTextures.push(cubeTexture); - cubeTexture.format = RGBAFormat; - cubeTexture.colorSpace = this._colorSpace; - cubeTexture.type = this._type as TextureDataType; - cubeTexture.minFilter = LinearMipMapLinearFilter; - cubeTexture.magFilter = LinearFilter; - cubeTexture.generateMipmaps = false; - - for (let j = 0; j < 6; j++) { - let view = new Uint8Array(buffer, offsetBytes, cpp * size * size); - let dataTexture = new DataTexture(view, size, size); - dataTexture.format = cubeTexture.format; - dataTexture.colorSpace = cubeTexture.colorSpace; - dataTexture.type = cubeTexture.type; - dataTexture.generateMipmaps = false; - - offsetBytes += cpp * size * size; - cubeTexture.images[j] = dataTexture; - dataTexture.needsUpdate = true; - } - - cubeTexture.needsUpdate = true; - size /= 2; - } - - this._cubeTexture = new CubeTexture(); - this._cubeTexture.format = RGBAFormat; - this._cubeTexture.colorSpace = this._colorSpace; - this._cubeTexture.type = this._type; - this._cubeTexture.minFilter = LinearMipMapLinearFilter; - this._cubeTexture.magFilter = LinearFilter; - this._cubeTexture.generateMipmaps = false; - - for (let i = 0; i < 6; i++) { - this._cubeTexture.image[i] = this._cubeTextures[0].images[i]; - for (let m = 1; m < numMips; m++) { - this._cubeTexture.mipmaps[m - 1] = this._cubeTextures[m]; - this._cubeTextures[m].needsUpdate = true; - } - } - this._cubeTexture.needsUpdate = true; - this._cubeTexture.maxLod = this._maxLod - 1; + this._cubeTexture.needsUpdate = true; + this._cubeTexture.maxLod = this._maxLod - 1; + } + + private convertToRGBABuffer(buffer: ArrayBuffer) { + const view = new Uint8Array( + buffer, + _HEADER_BYTES_, + buffer.byteLength - _HEADER_BYTES_ + ); + const stride = this._format === 1022 ? 3 : 4; + const newBufferLength = (4 * view.length) / stride; + const newBuffer = new ArrayBuffer(newBufferLength); + const newView = new DataView(newBuffer); + let n = 0; + const offset = view.length / stride; + if (stride === 3) { + for (let i = 0; i < offset; i++) { + newView.setUint8(n++, view[i]); + newView.setUint8(n++, view[i + offset]); + newView.setUint8(n++, view[i + 2 * offset]); + newView.setUint8(n++, 255); + } + } else { + for (let i = 0; i < offset; i++) { + newView.setUint8(n++, view[i]); + newView.setUint8(n++, view[i + offset]); + newView.setUint8(n++, view[i + 2 * offset]); + newView.setUint8(n++, view[i + 3 * offset]); + } } - private convertToRGBABuffer(buffer: ArrayBuffer) { - let view = new Uint8Array(buffer, _HEADER_BYTES_, buffer.byteLength - _HEADER_BYTES_); - const stride = this._format === 1022 ? 3 : 4; - const newBufferLength = 4 * view.length / stride; - let newBuffer = new ArrayBuffer(newBufferLength); - let newView = new DataView(newBuffer); - let n = 0; - let offset = view.length / stride; - if (stride === 3) { - for (let i = 0; i < offset; i++) { - newView.setUint8(n++, view[i]); - newView.setUint8(n++, view[i + offset]); - newView.setUint8(n++, view[i + 2 * offset]); - newView.setUint8(n++, 255); - } - } else { - for (let i = 0; i < offset; i++) { - newView.setUint8(n++, view[i]); - newView.setUint8(n++, view[i + offset]); - newView.setUint8(n++, view[i + 2 * offset]); - newView.setUint8(n++, view[i + 3 * offset]); - } - } - - return newBuffer; - } + return newBuffer; + } - private parseData_(buffer: ArrayBuffer) { - this.parseHeader_(buffer); - let offsetByes = _HEADER_BYTES_; - offsetByes = 0; - let newBuffer = this.convertToRGBABuffer(buffer); - this.parseBufferData_(newBuffer, offsetByes); - } + private parseData_(buffer: ArrayBuffer) { + this.parseHeader_(buffer); + let offsetByes = _HEADER_BYTES_; + offsetByes = 0; + const newBuffer = this.convertToRGBABuffer(buffer); + this.parseBufferData_(newBuffer, offsetByes); + } } diff --git a/src/client/loader/environment_map/environmentLoader.ts b/src/client/loader/environment_map/environmentLoader.ts index 0c15dfb..c7bc124 100644 --- a/src/client/loader/environment_map/environmentLoader.ts +++ b/src/client/loader/environment_map/environmentLoader.ts @@ -208,4 +208,4 @@ export class EnvironmentLoader { } } } -} \ No newline at end of file +} diff --git a/src/client/renderer/background-environment.ts b/src/client/renderer/background-environment.ts index 041da90..092e988 100644 --- a/src/client/renderer/background-environment.ts +++ b/src/client/renderer/background-environment.ts @@ -58,7 +58,7 @@ export class BackgroundEnvironment { } private _updateParameters(parameters: any) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; } diff --git a/src/client/renderer/baked-ground-contact-shadow.ts b/src/client/renderer/baked-ground-contact-shadow.ts index 0e74fd5..0491924 100644 --- a/src/client/renderer/baked-ground-contact-shadow.ts +++ b/src/client/renderer/baked-ground-contact-shadow.ts @@ -208,7 +208,7 @@ export class BakedGroundContactShadow { } public updateParameters(parameters: BakedGroundContactShadowParameters) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; } diff --git a/src/client/renderer/effect-pass.ts b/src/client/renderer/effect-pass.ts index a767461..7a42b36 100644 --- a/src/client/renderer/effect-pass.ts +++ b/src/client/renderer/effect-pass.ts @@ -147,7 +147,7 @@ export class HBAOEffect { size, size, RGBAFormat, - UnsignedByteType, + UnsignedByteType ); this._noiseTexture.wrapS = RepeatWrapping; this._noiseTexture.wrapT = RepeatWrapping; @@ -210,10 +210,10 @@ export class HBAOEffect { this._hbaoMaterial.uniforms.tDepth.value = depthTexture; this._hbaoMaterial.uniforms.resolution.value.set(this._width, this._height); this._hbaoMaterial.uniforms.cameraProjectionMatrix.value.copy( - camera.projectionMatrix, + camera.projectionMatrix ); this._hbaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy( - camera.projectionMatrixInverse, + camera.projectionMatrixInverse ); const currentCamera = camera as PerspectiveCamera | OrthographicCamera; this._hbaoMaterial.uniforms.cameraNear.value = currentCamera.near; @@ -249,7 +249,7 @@ export class HBAOEffect { } public updateParameters(parameters: any) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; this.needsUpdate = true; @@ -269,14 +269,14 @@ export class HBAOEffect { renderer: WebGLRenderer, camera: Camera, scene: Scene, - renderTarget?: WebGLRenderTarget, + renderTarget?: WebGLRenderTarget ) { const hbaoMaterial = this._getMaterial(camera, this.needsUpdate); this.needsUpdate = false; this._renderPass.renderScreenSpace( renderer, hbaoMaterial, - renderTarget ? renderTarget : this._getRenderTargets(), + renderTarget ? renderTarget : this._getRenderTargets() ); } } @@ -356,7 +356,7 @@ export class PoissonDenoiseEffect implements DenoisePass { size, size, RGBAFormat, - UnsignedByteType, + UnsignedByteType ); this._noiseTexture.wrapS = RepeatWrapping; this._noiseTexture.wrapT = RepeatWrapping; @@ -398,7 +398,7 @@ export class PoissonDenoiseEffect implements DenoisePass { this._pdMaterial.defines.SAMPLE_VECTORS = generatePdSamplePointInitializer( this.parameters.samples, - this.parameters.rings, + this.parameters.rings ); this._pdMaterial.defines.NORMAL_VECTOR_TYPE = this._normalVectorSourceType === @@ -420,7 +420,7 @@ export class PoissonDenoiseEffect implements DenoisePass { this._pdMaterial.uniforms.tDepth.value = depthTexture; this._pdMaterial.uniforms.resolution.value.set(this._width, this._height); this._pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy( - camera.projectionMatrixInverse, + camera.projectionMatrixInverse ); this._pdMaterial.uniforms.lumaPhi.value = this.parameters.lumaPhi; this._pdMaterial.uniforms.depthPhi.value = this.parameters.depthPhi; @@ -459,7 +459,7 @@ export class PoissonDenoiseEffect implements DenoisePass { } public updateParameters(parameters: any) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; this.needsUpdate = true; @@ -494,7 +494,7 @@ export class PoissonDenoiseEffect implements DenoisePass { pdMaterial, outputRenderTarget, 0xffffff, - 1.0, + 1.0 ); } } diff --git a/src/client/renderer/ground-reflection-pass.ts b/src/client/renderer/ground-reflection-pass.ts index 84a077d..30e233b 100644 --- a/src/client/renderer/ground-reflection-pass.ts +++ b/src/client/renderer/ground-reflection-pass.ts @@ -130,7 +130,7 @@ export class GroundReflectionPass { private _newRenderTarget(createDepthTexture: boolean): WebGLRenderTarget { const _width = this._width / this.parameters.renderTargetDownScale; const _height = this._height / this.parameters.renderTargetDownScale; - let additionalParameters: any = {}; + const additionalParameters: any = {}; if (createDepthTexture) { const depthTexture = new DepthTexture(_width, _height); depthTexture.format = DepthStencilFormat; @@ -176,7 +176,7 @@ export class GroundReflectionPass { } public updateParameters(parameters: GroundReflectionParameters) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; } diff --git a/src/client/renderer/light-source-detection-debug.ts b/src/client/renderer/light-source-detection-debug.ts index 3687815..ad1b9bb 100644 --- a/src/client/renderer/light-source-detection-debug.ts +++ b/src/client/renderer/light-source-detection-debug.ts @@ -52,8 +52,8 @@ export class LightSourceDetectorDebug { lightGraph: LightGraph, maxNoOfLightSources?: number ) { - let singleLightSamples: LightSample[] = []; - let clusterLightSamples: LightSample[] = []; + const singleLightSamples: LightSample[] = []; + const clusterLightSamples: LightSample[] = []; for (let i = 0; i < this._lightSourceDetector.lightGraph.noOfNodes; ++i) { if (lightGraph.adjacent[i].length === 0) { singleLightSamples.push(lightSamples[i]); diff --git a/src/client/renderer/light-source-detection.ts b/src/client/renderer/light-source-detection.ts index 19388a0..c2f269c 100644 --- a/src/client/renderer/light-source-detection.ts +++ b/src/client/renderer/light-source-detection.ts @@ -137,7 +137,7 @@ export class TextureConverter { renderer.setRenderTarget(renderTargetBackup); const grayscaleTexture = envMapDecodeTarget.texture; const floatType = envMapDecodeTarget.texture.type === FloatType; - let pixelBuffer: Uint8Array | Float32Array = floatType + const pixelBuffer: Uint8Array | Float32Array = floatType ? new Float32Array(targetWidth * targetHeight * 4) : new Uint8Array(targetWidth * targetHeight * 4); renderer.readRenderTargetPixels( diff --git a/src/client/renderer/outline-pass.ts b/src/client/renderer/outline-pass.ts index d4c289f..c11e174 100644 --- a/src/client/renderer/outline-pass.ts +++ b/src/client/renderer/outline-pass.ts @@ -328,7 +328,7 @@ export class OutlinePass extends Pass { if (object.isMesh || object.isSprite) { // only meshes and sprites are supported by OutlinePass - let bFound = selectedMeshes.some( + const bFound = selectedMeshes.some( (selectedMesh) => selectedMesh.id === object.id ); if (bFound === false) { diff --git a/src/client/renderer/outline-renderer.ts b/src/client/renderer/outline-renderer.ts index e48168c..4d3ec40 100644 --- a/src/client/renderer/outline-renderer.ts +++ b/src/client/renderer/outline-renderer.ts @@ -82,7 +82,7 @@ export class OutLineRenderer { } public updateParameters(parameters: OutlineParameters): void { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; } diff --git a/src/client/renderer/pass/ao-pass.ts b/src/client/renderer/pass/ao-pass.ts index 735035e..1246d38 100644 --- a/src/client/renderer/pass/ao-pass.ts +++ b/src/client/renderer/pass/ao-pass.ts @@ -291,7 +291,7 @@ export class AORenderPass { } public updateParameters(parameters: AORenderPassParameters) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; this.needsUpdate = true; diff --git a/src/client/renderer/pass/poisson-denoise-pass.ts b/src/client/renderer/pass/poisson-denoise-pass.ts index 61f07be..5b0902c 100644 --- a/src/client/renderer/pass/poisson-denoise-pass.ts +++ b/src/client/renderer/pass/poisson-denoise-pass.ts @@ -229,7 +229,7 @@ export class PoissonDenoiseRenderPass implements DenoisePass { } public updateParameters(parameters: PoissonDenoisePassParameters) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; this.needsUpdate = true; diff --git a/src/client/renderer/screen-space-reflection.ts b/src/client/renderer/screen-space-reflection.ts index ff65857..1641721 100644 --- a/src/client/renderer/screen-space-reflection.ts +++ b/src/client/renderer/screen-space-reflection.ts @@ -20,7 +20,6 @@ import { FramebufferTexture, LinearFilter, Matrix4, - NearestFilter, ShaderMaterial, UniformsUtils, Vector2, @@ -90,7 +89,7 @@ export class ScreenSpaceReflection { width: number, height: number, samples: number, - parameters?: any, + parameters?: any ) { if (parameters?.gBufferRenderTarget) { this._sharedGBufferRenderTarget = parameters?.gBufferRenderTarget; @@ -101,7 +100,7 @@ export class ScreenSpaceReflection { this._ssrRenderPass = new SSRRenderPass(width, height, parameters); this._blendMaterial = new CopyTransformMaterial( {}, - CopyMaterialBlendMode.DEFAULT, + CopyMaterialBlendMode.DEFAULT ); this._renderPass = parameters?.renderPass || new RenderPass(); } @@ -131,7 +130,7 @@ export class ScreenSpaceReflection { scene: Scene, camera: Camera, illuminationBufferTexture: Texture | null, - fadeInMix: number = 0, + fadeInMix: number = 0 ): void { if ( !this._ssrRenderPass.parameters.enabled || @@ -144,11 +143,11 @@ export class ScreenSpaceReflection { this._copyDiffuseFrameTexture ?? new FramebufferTexture( this._width * renderer.getPixelRatio(), - this._height * renderer.getPixelRatio(), + this._height * renderer.getPixelRatio() ); renderer.copyFramebufferToTexture( new Vector2(), - this._copyDiffuseFrameTexture, + this._copyDiffuseFrameTexture ); this.gBufferRenderTarget.render(renderer, scene, camera); this._ssrRenderPass.inputTexture = this._copyDiffuseFrameTexture; @@ -163,7 +162,7 @@ export class ScreenSpaceReflection { private _renderToTarget( renderer: WebGLRenderer, finalTexture: Texture | null, - fadeInMix: number = 0, + fadeInMix: number = 0 ): void { this._blendMaterial.update({ texture: finalTexture, @@ -180,7 +179,7 @@ export class ScreenSpaceReflection { this._renderPass.renderScreenSpace( renderer, this._blendMaterial, - renderer.getRenderTarget(), + renderer.getRenderTarget() ); } } @@ -247,7 +246,7 @@ export class SSRRenderPass { } if (updateShader) { const diagnalDist = Math.sqrt( - this._width * this._width + this._height * this._height, + this._width * this._width + this._height * this._height ); this._ssrMaterial.defines.MAX_STEP = Math.min(diagnalDist, 400); this._ssrMaterial.defines.NO_GROUND_REFLECTION = 1; @@ -283,10 +282,10 @@ export class SSRRenderPass { this._ssrMaterial.uniforms.resolution.value.set(this._width, this._height); this._ssrMaterial.uniforms.cameraMatrixWorld.value.copy(camera.matrixWorld); this._ssrMaterial.uniforms.cameraProjectionMatrix.value.copy( - camera.projectionMatrix, + camera.projectionMatrix ); this._ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy( - camera.projectionMatrixInverse, + camera.projectionMatrixInverse ); this._ssrMaterial.uniforms.sceneBoxMin.value.copy(this._sceneBoxMin); this._ssrMaterial.uniforms.sceneBoxMax.value.copy(this._sceneBoxMax); @@ -327,7 +326,7 @@ export class SSRRenderPass { } public updateParameters(parameters: any) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; this.needsUpdate = true; @@ -347,14 +346,14 @@ export class SSRRenderPass { renderer: WebGLRenderer, camera: Camera, scene: Scene, - renderTarget?: WebGLRenderTarget, + renderTarget?: WebGLRenderTarget ) { const hbaoMaterial = this._getMaterial(camera, this.needsUpdate); this.needsUpdate = false; this._renderPass.renderScreenSpace( renderer, hbaoMaterial, - renderTarget ? renderTarget : this._getRenderTargets(), + renderTarget ? renderTarget : this._getRenderTargets() ); } } diff --git a/src/client/renderer/screen-space-shadow-map.ts b/src/client/renderer/screen-space-shadow-map.ts index e94020c..30ead95 100644 --- a/src/client/renderer/screen-space-shadow-map.ts +++ b/src/client/renderer/screen-space-shadow-map.ts @@ -181,7 +181,7 @@ export class ScreenSpaceShadowMap { } public updateParameters(parameters: ScreenSpaceShadowMapParameters) { - for (let propertyName in parameters) { + for (const propertyName in parameters) { if (this.parameters.hasOwnProperty(propertyName)) { this.parameters[propertyName] = parameters[propertyName]; } @@ -415,7 +415,7 @@ export class ScreenSpaceShadowMap { } private _getSortedShadowLightSources(): ActiveShadowLight[] { - let activeShadowLights: ActiveShadowLight[] = []; + const activeShadowLights: ActiveShadowLight[] = []; this._shadowLightSources.forEach((item) => activeShadowLights.push(...item.prepareRenderShadow()) ); @@ -441,7 +441,7 @@ export class ScreenSpaceShadowMap { activeShadowLights: ActiveShadowLight[] ) { let sumOfShadowLightIntensity = 0; - let maximumNumberOfLightSources = + const maximumNumberOfLightSources = this.parameters.maximumNumberOfLightSources; let noOfLights = 0; activeShadowLights.forEach((shadowLight) => { diff --git a/src/client/renderer/shaders/ao-shader.ts b/src/client/renderer/shaders/ao-shader.ts index 978219a..a7d0148 100644 --- a/src/client/renderer/shaders/ao-shader.ts +++ b/src/client/renderer/shaders/ao-shader.ts @@ -32,7 +32,7 @@ const generateAoSamples = (samples: number, cosineWeighted: boolean) => { const kernel = []; for (let sampleIndex = 0; sampleIndex < samples; sampleIndex++) { const spiralAngle = sampleIndex * Math.PI * (3 - Math.sqrt(5)); - let z = 0.01 + (sampleIndex / (samples - 1)) * 0.99; + const z = 0.01 + (sampleIndex / (samples - 1)) * 0.99; const radius = cosineWeighted ? Math.sqrt(1 - z * z) : 1 - z; const x = Math.cos(spiralAngle) * radius; const y = Math.sin(spiralAngle) * radius; diff --git a/src/client/renderer/shadow-and-ao-pass.ts b/src/client/renderer/shadow-and-ao-pass.ts index f757245..3f997a1 100644 --- a/src/client/renderer/shadow-and-ao-pass.ts +++ b/src/client/renderer/shadow-and-ao-pass.ts @@ -301,7 +301,7 @@ export class ShadowAndAoPass { private _updatePassParameters(parameters: ShadowAndAoPassParameters) { if (parameters?.shadow) { - for (let propertyName in parameters.shadow) { + for (const propertyName in parameters.shadow) { if (this.parameters.shadow.hasOwnProperty(propertyName)) { this.parameters.shadow[propertyName] = parameters.shadow[propertyName]; @@ -310,7 +310,7 @@ export class ShadowAndAoPass { } } if (parameters?.ao) { - for (let propertyName in parameters.ao) { + for (const propertyName in parameters.ao) { if (this.parameters.ao.hasOwnProperty(propertyName)) { this.parameters.ao[propertyName] = parameters.ao[propertyName]; this.shadowAndAoRenderTargets.parametersNeedsUpdate = true; @@ -324,7 +324,7 @@ export class ShadowAndAoPass { if (this._poissonDenoisePass) { this._poissonDenoisePass?.updateParameters(parameters?.poissonDenoise); } else { - for (let propertyName in parameters.poissonDenoise) { + for (const propertyName in parameters.poissonDenoise) { if (this.parameters.poissonDenoise.hasOwnProperty(propertyName)) { this.parameters.poissonDenoise[propertyName] = parameters.poissonDenoise[propertyName]; diff --git a/src/client/scene/controls.ts b/src/client/scene/controls.ts index 8714f24..ab47057 100644 --- a/src/client/scene/controls.ts +++ b/src/client/scene/controls.ts @@ -1,35 +1,38 @@ -import { - Camera, - Object3D, - WebGLRenderer -} from 'three' -import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' +import type { Camera, Object3D, WebGLRenderer } from 'three'; +import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'; import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js'; export class Controls { - public renderer: WebGLRenderer; - public canvas: HTMLCanvasElement; - public camera: Camera; - public orbitControls: OrbitControls; + public renderer: WebGLRenderer; + public canvas: HTMLCanvasElement; + public camera: Camera; + public orbitControls: OrbitControls; - constructor(renderer: WebGLRenderer, camera: Camera, canvas?: HTMLCanvasElement) { - this.renderer = renderer - this.canvas = canvas || this.renderer.domElement; - this.camera = camera - this.orbitControls = new OrbitControls(camera, this.canvas) - } + constructor( + renderer: WebGLRenderer, + camera: Camera, + canvas?: HTMLCanvasElement + ) { + this.renderer = renderer; + this.canvas = canvas || this.renderer.domElement; + this.camera = camera; + this.orbitControls = new OrbitControls(camera, this.canvas); + } - public addTransformControl(object: Object3D, target: Object3D): TransformControls { - const control = new TransformControls(this.camera, this.canvas); - control.addEventListener( 'dragging-changed', (event: any) => { - this.orbitControls.enabled = !event.value; - } ); - control.attach(object); - target.add(control); - return control; - } + public addTransformControl( + object: Object3D, + target: Object3D + ): TransformControls { + const control = new TransformControls(this.camera, this.canvas); + control.addEventListener('dragging-changed', (event: any) => { + this.orbitControls.enabled = !event.value; + }); + control.attach(object); + target.add(control); + return control; + } - public update() { - this.orbitControls.update() - } -} \ No newline at end of file + public update() { + this.orbitControls.update(); + } +} diff --git a/src/client/scene/dimensioningArrow.ts b/src/client/scene/dimensioningArrow.ts index ab6ec71..5a544af 100644 --- a/src/client/scene/dimensioningArrow.ts +++ b/src/client/scene/dimensioningArrow.ts @@ -1,239 +1,346 @@ +import type { + Camera, + ColorRepresentation, + Material, + Object3D, + WebGLRenderer, +} from 'three'; import { - Camera, - Color, - ColorRepresentation, - DoubleSide, - Group, - Material, - Matrix4, - Mesh, - NoBlending, - Object3D, - PlaneGeometry, - ShaderMaterial, - UniformsUtils, - Vector2, - Vector3, - WebGLRenderer, + Color, + DoubleSide, + Group, + Matrix4, + Mesh, + NoBlending, + PlaneGeometry, + ShaderMaterial, + UniformsUtils, + Vector2, + Vector3, } from 'three'; import { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer.js'; export interface DimensioningArrowParameters { - shaftPixelWidth: number; - shaftPixelOffset: number; - arrowPixelWidth: number; - arrowPixelHeight: number; - color: ColorRepresentation; - labelClass: string; - deviceRatio: number; - autoLabelTextUpdate: boolean; - autoLabelRotationUpdate: boolean; + shaftPixelWidth: number; + shaftPixelOffset: number; + arrowPixelWidth: number; + arrowPixelHeight: number; + color: ColorRepresentation; + labelClass: string; + deviceRatio: number; + autoLabelTextUpdate: boolean; + autoLabelRotationUpdate: boolean; } export class DimensioningArrow extends Group { - public parameters: DimensioningArrowParameters; - public arrowNeedsUpdate: boolean = true; - public startPosition: Vector3; - public endPosition: Vector3; - private startShaft: Mesh; - private endShaft: Mesh; - private startShaftMaterial: DimensioningArrowShaftMaterial; - private endShaftMaterial: DimensioningArrowShaftMaterial; - private startArrow: Mesh; - private endArrow: Mesh; - private startArrowMaterial: DimensioningArrowMaterial; - private endArrowMaterial: DimensioningArrowMaterial; - private arrowLabel: CSS2DObject; - private labelTextClientWidth: number = 0; - - constructor(start: Vector3, end: Vector3, parameters?: any) { - super(); - this.startPosition = start.clone(); - this.endPosition = end.clone(); - this.parameters = { - shaftPixelWidth: 10.0, - shaftPixelOffset: 3.0, - arrowPixelWidth: 30.0, - arrowPixelHeight: 50.0, - color: 0x000000, - labelClass: 'label', - deviceRatio: 1, - autoLabelTextUpdate: true, - autoLabelRotationUpdate: true, - ...parameters, - } - this.startShaftMaterial = new DimensioningArrowShaftMaterial(); - this.startShaft = new Mesh(new PlaneGeometry(2, 1).translate(0, 0.5, 0), this.startShaftMaterial); - this.startShaft.onBeforeRender = (renderer, scene, camera, geometry, material, group) => { - this.updateShaftMaterial(true, renderer, camera, material); - }; - this.add(this.startShaft); - this.endShaftMaterial = new DimensioningArrowShaftMaterial(); - this.endShaft = new Mesh(new PlaneGeometry(2, 1).translate(0, 0.5, 0), this.endShaftMaterial); - this.endShaft.onBeforeRender = (renderer, scene, camera, geometry, material, group) => { - this.updateShaftMaterial(false, renderer, camera, material); - }; - this.add(this.endShaft); - this.startArrowMaterial = new DimensioningArrowMaterial(); - this.startArrow = new Mesh(new PlaneGeometry(2, 1).translate(0, 0.5, 0), this.startArrowMaterial); - this.startArrow.onBeforeRender = (renderer, scene, camera, geometry, material, group) => { - this.updateArrowMaterial(true, renderer, camera, material); - }; - this.add(this.startArrow); - this.endArrowMaterial = new DimensioningArrowMaterial(); - this.endArrow = new Mesh(new PlaneGeometry(2, 1).translate(0, 0.5, 0), this.endArrowMaterial); - this.endArrow.onBeforeRender = (renderer, scene, camera, geometry, material, group) => { - this.updateArrowMaterial(false, renderer, camera, material); - }; - this.add(this.endArrow); - this.arrowLabel = this.createArrowLabel('0.000', this.parameters); - this.add(this.arrowLabel); - this.updateArrow(); - } - - private createArrowLabel(text: string, parameters?: any): CSS2DObject { - const outerLabelDiv = document.createElement('div'); - const labelDiv = document.createElement('div'); - outerLabelDiv.appendChild(labelDiv); - labelDiv.className = parameters.labelClass ?? ''; - labelDiv.textContent = text; - labelDiv.style.backgroundColor = 'transparent'; - labelDiv.style.color = new Color(parameters.color ?? 0x000000).getStyle(); - const labelObject = new CSS2DObject(outerLabelDiv); - labelObject.position.set(0, 0, 0); - // @ts-ignore - labelObject.center.set(parameters.origin?.x ?? 0.5, parameters.origin?.y ?? 0.5); - labelObject.layers.set(0); - return labelObject; - } - - public setPosition(start: Vector3, end: Vector3, offsetStart: number = 0, offsetEnd: number = 0) { - const direction = end.clone().sub(start).normalize(); - this.startPosition.copy(start.clone().add(direction.clone().multiplyScalar(offsetStart))); - this.endPosition.copy(end.clone().add(direction.clone().multiplyScalar(-offsetEnd))); - this.arrowNeedsUpdate = true; + public parameters: DimensioningArrowParameters; + public arrowNeedsUpdate: boolean = true; + public startPosition: Vector3; + public endPosition: Vector3; + private startShaft: Mesh; + private endShaft: Mesh; + private startShaftMaterial: DimensioningArrowShaftMaterial; + private endShaftMaterial: DimensioningArrowShaftMaterial; + private startArrow: Mesh; + private endArrow: Mesh; + private startArrowMaterial: DimensioningArrowMaterial; + private endArrowMaterial: DimensioningArrowMaterial; + private arrowLabel: CSS2DObject; + private labelTextClientWidth: number = 0; + + constructor(start: Vector3, end: Vector3, parameters?: any) { + super(); + this.startPosition = start.clone(); + this.endPosition = end.clone(); + this.parameters = { + shaftPixelWidth: 10.0, + shaftPixelOffset: 3.0, + arrowPixelWidth: 30.0, + arrowPixelHeight: 50.0, + color: 0x000000, + labelClass: 'label', + deviceRatio: 1, + autoLabelTextUpdate: true, + autoLabelRotationUpdate: true, + ...parameters, + }; + this.startShaftMaterial = new DimensioningArrowShaftMaterial(); + this.startShaft = new Mesh( + new PlaneGeometry(2, 1).translate(0, 0.5, 0), + this.startShaftMaterial + ); + this.startShaft.onBeforeRender = ( + renderer, + _scene, + camera, + _geometry, + material, + _group + ) => { + this.updateShaftMaterial(true, renderer, camera, material); + }; + this.add(this.startShaft); + this.endShaftMaterial = new DimensioningArrowShaftMaterial(); + this.endShaft = new Mesh( + new PlaneGeometry(2, 1).translate(0, 0.5, 0), + this.endShaftMaterial + ); + this.endShaft.onBeforeRender = ( + renderer, + _scene, + camera, + _geometry, + material, + _group + ) => { + this.updateShaftMaterial(false, renderer, camera, material); + }; + this.add(this.endShaft); + this.startArrowMaterial = new DimensioningArrowMaterial(); + this.startArrow = new Mesh( + new PlaneGeometry(2, 1).translate(0, 0.5, 0), + this.startArrowMaterial + ); + this.startArrow.onBeforeRender = ( + renderer, + _scene, + camera, + _geometry, + material, + _group + ) => { + this.updateArrowMaterial(true, renderer, camera, material); + }; + this.add(this.startArrow); + this.endArrowMaterial = new DimensioningArrowMaterial(); + this.endArrow = new Mesh( + new PlaneGeometry(2, 1).translate(0, 0.5, 0), + this.endArrowMaterial + ); + this.endArrow.onBeforeRender = ( + renderer, + _scene, + camera, + _geometry, + material, + _group + ) => { + this.updateArrowMaterial(false, renderer, camera, material); + }; + this.add(this.endArrow); + this.arrowLabel = this.createArrowLabel('0.000', this.parameters); + this.add(this.arrowLabel); + this.updateArrow(); + } + + private createArrowLabel(text: string, parameters?: any): CSS2DObject { + const outerLabelDiv = document.createElement('div'); + const labelDiv = document.createElement('div'); + outerLabelDiv.appendChild(labelDiv); + labelDiv.className = parameters.labelClass ?? ''; + labelDiv.textContent = text; + labelDiv.style.backgroundColor = 'transparent'; + labelDiv.style.color = new Color(parameters.color ?? 0x000000).getStyle(); + const labelObject = new CSS2DObject(outerLabelDiv); + labelObject.position.set(0, 0, 0); + // @ts-ignore + labelObject.center.set( + parameters.origin?.x ?? 0.5, + parameters.origin?.y ?? 0.5 + ); + labelObject.layers.set(0); + return labelObject; + } + + public setPosition( + start: Vector3, + end: Vector3, + offsetStart: number = 0, + offsetEnd: number = 0 + ) { + const direction = end.clone().sub(start).normalize(); + this.startPosition.copy( + start.clone().add(direction.clone().multiplyScalar(offsetStart)) + ); + this.endPosition.copy( + end.clone().add(direction.clone().multiplyScalar(-offsetEnd)) + ); + this.arrowNeedsUpdate = true; + } + + public setAngle(angleDegree: number) { + const rotateStyle = `${angleDegree.toFixed(0)}deg`; + const labelDiv = this.arrowLabel.element.children[0] as HTMLDivElement; + labelDiv.style.rotate = rotateStyle; + } + + public setLabel(text: string) { + const labelDiv = this.arrowLabel.element.children[0] as HTMLDivElement; + labelDiv.textContent = text; + this.labelTextClientWidth = + labelDiv.clientWidth * this.parameters.deviceRatio; + } + + public updateArrow() { + const start = this.startPosition.clone().applyMatrix4(this.matrixWorld); + const end = this.endPosition.clone().applyMatrix4(this.matrixWorld); + const direction = end.clone().sub(start); + const length = direction.length(); + direction.multiplyScalar(1 / length); + const rotationAxis = new Vector3(0, 1, 0).cross(direction); + const rotationAngle = Math.acos(new Vector3(0, 1, 0).dot(direction)); + this.setModelMatrix( + this.startShaft, + start, + length, + rotationAxis, + rotationAngle + ); + this.setModelMatrix( + this.endShaft, + end, + length, + rotationAxis, + rotationAngle + ); + this.setModelMatrix(this.startArrow, start, 1, rotationAxis, rotationAngle); + this.setModelMatrix( + this.endArrow, + end, + 1, + rotationAxis, + rotationAngle + Math.PI + ); + } + + public updateArrowLabel(renderer: WebGLRenderer, camera: Camera) { + const distanceText = this.startPosition + .distanceTo(this.endPosition) + .toFixed(3); + const start = this.startPosition + .clone() + .applyMatrix4(this.matrixWorld) + .applyMatrix4(camera.matrixWorldInverse) + .applyMatrix4(camera.projectionMatrix); + const end = this.endPosition + .clone() + .applyMatrix4(this.matrixWorld) + .applyMatrix4(camera.matrixWorldInverse) + .applyMatrix4(camera.projectionMatrix); + const center = end + .clone() + .add(start) + .multiplyScalar(0.5) + .applyMatrix4(camera.projectionMatrixInverse) + .applyMatrix4(camera.matrixWorld); + this.arrowLabel.position.copy(center); + const renderTarget = renderer.getRenderTarget(); + const width = renderTarget?.width ?? renderer.domElement.clientWidth; + const height = renderTarget?.height ?? renderer.domElement.clientHeight; + const direction = end.clone().sub(start); + const angle = + (Math.atan2(-direction.y, (direction.x * width) / height) * 180) / + Math.PI; + if (this.parameters.autoLabelRotationUpdate) { + this.setAngle(angle); } - - public setAngle(angleDegree: number) { - const rotateStyle = `${angleDegree.toFixed(0)}deg`; - const labelDiv = this.arrowLabel.element.children[0] as HTMLDivElement; - labelDiv.style.rotate = rotateStyle; - } - - public setLabel(text: string) { - const labelDiv = this.arrowLabel.element.children[0] as HTMLDivElement; - labelDiv.textContent = text; - this.labelTextClientWidth = labelDiv.clientWidth * this.parameters.deviceRatio; + if (this.parameters.autoLabelTextUpdate) { + this.setLabel(distanceText); } - - public updateArrow() { - const start = this.startPosition.clone().applyMatrix4(this.matrixWorld); - const end = this.endPosition.clone().applyMatrix4(this.matrixWorld); - const direction = end.clone().sub(start); - const length = direction.length(); - direction.multiplyScalar(1 / length); - const rotationAxis = new Vector3(0, 1, 0).cross(direction); - const rotationAngle = Math.acos(new Vector3(0, 1, 0).dot(direction)); - this.setModelMatrix(this.startShaft, start, length, rotationAxis, rotationAngle); - this.setModelMatrix(this.endShaft, end, length, rotationAxis, rotationAngle); - this.setModelMatrix(this.startArrow, start, 1, rotationAxis, rotationAngle); - this.setModelMatrix(this.endArrow, end, 1, rotationAxis, rotationAngle + Math.PI); + } + + private setModelMatrix( + object: Object3D, + start: Vector3, + length: number, + rotationAxis: Vector3, + rotationAngle: number + ) { + object.scale.set(1, 1, 1); + object.rotation.set(0, 0, 0); + object.position.set(0, 0, 0); + object.applyMatrix4(new Matrix4().makeScale(1, length * 0.5, 1)); + object.applyMatrix4( + new Matrix4().makeRotationAxis(rotationAxis, rotationAngle) + ); + object.applyMatrix4( + new Matrix4().makeTranslation(start.x, start.y, start.z) + ); + } + + public updateShaftMaterial( + startArrow: boolean, + renderer: WebGLRenderer, + camera: Camera, + material: Material + ) { + this.updateMatrixWorld(); + if (material instanceof DimensioningArrowShaftMaterial) { + const renderTarget = renderer.getRenderTarget(); + const viewportSize = new Vector2(); + renderer.getSize(viewportSize); + const width = renderTarget?.width ?? viewportSize.x; + const height = renderTarget?.height ?? viewportSize.y; + const start = this.startPosition.clone().applyMatrix4(this.matrixWorld); + const end = this.endPosition.clone().applyMatrix4(this.matrixWorld); + material.update({ + width, + height, + camera, + start: startArrow ? start : end, + end: startArrow ? end : start, + shaftPixelWidth: this.parameters.shaftPixelWidth, + shaftPixelOffset: this.parameters.shaftPixelOffset, + arrowPixelSize: new Vector2( + this.parameters.arrowPixelWidth, + this.parameters.arrowPixelHeight + ), + labelPixelWidth: this.labelTextClientWidth, + color: this.parameters.color, + }); } - - public updateArrowLabel(renderer: WebGLRenderer, camera: Camera) { - const distanceText = this.startPosition.distanceTo(this.endPosition).toFixed(3); - const start = this.startPosition.clone() - .applyMatrix4(this.matrixWorld) - .applyMatrix4(camera.matrixWorldInverse) - .applyMatrix4(camera.projectionMatrix); - const end = this.endPosition.clone() - .applyMatrix4(this.matrixWorld) - .applyMatrix4(camera.matrixWorldInverse) - .applyMatrix4(camera.projectionMatrix); - const center = end.clone().add(start).multiplyScalar(0.5) - .applyMatrix4(camera.projectionMatrixInverse) - .applyMatrix4(camera.matrixWorld); - this.arrowLabel.position.copy(center); - const renderTarget = renderer.getRenderTarget(); - const width = renderTarget?.width ?? renderer.domElement.clientWidth; - const height = renderTarget?.height ?? renderer.domElement.clientHeight; - const direction = end.clone().sub(start); - const angle = Math.atan2(-direction.y, direction.x * width / height) * 180 / Math.PI; - if (this.parameters.autoLabelRotationUpdate) { - this.setAngle(angle); - } - if (this.parameters.autoLabelTextUpdate) { - this.setLabel(distanceText); - } + if (this.arrowNeedsUpdate) { + this.arrowNeedsUpdate = false; + this.updateArrowLabel(renderer, camera); + this.updateArrow(); } - - private setModelMatrix(object: Object3D, start: Vector3, length: number, rotationAxis: Vector3, rotationAngle: number) { - object.scale.set(1, 1, 1); - object.rotation.set(0, 0, 0); - object.position.set(0, 0, 0); - object.applyMatrix4(new Matrix4().makeScale(1, length * 0.5, 1)); - object.applyMatrix4(new Matrix4().makeRotationAxis(rotationAxis, rotationAngle)); - object.applyMatrix4(new Matrix4().makeTranslation(start.x, start.y, start.z)); + } + + public updateArrowMaterial( + startArrow: boolean, + renderer: WebGLRenderer, + camera: Camera, + material: Material + ) { + this.updateMatrixWorld(); + if (material instanceof DimensioningArrowMaterial) { + const renderTarget = renderer.getRenderTarget(); + const width = renderTarget?.width ?? renderer.domElement.clientWidth; + const height = renderTarget?.height ?? renderer.domElement.clientHeight; + const start = this.startPosition.clone().applyMatrix4(this.matrixWorld); + const end = this.endPosition.clone().applyMatrix4(this.matrixWorld); + material.update({ + width, + height, + camera, + start: startArrow ? start : end, + end: startArrow ? end : start, + arrowPixelSize: new Vector2( + this.parameters.arrowPixelWidth, + this.parameters.arrowPixelHeight + ), + color: this.parameters.color, + }); } - - public updateShaftMaterial(startArrow: boolean, renderer: WebGLRenderer, camera: Camera, material: Material) { - this.updateMatrixWorld(); - if (material instanceof DimensioningArrowShaftMaterial) { - const renderTarget = renderer.getRenderTarget(); - const viewportSize = new Vector2(); - renderer.getSize(viewportSize); - const width = renderTarget?.width ?? viewportSize.x; - const height = renderTarget?.height ?? viewportSize.y; - const start = this.startPosition.clone().applyMatrix4(this.matrixWorld); - const end = this.endPosition.clone().applyMatrix4(this.matrixWorld); - material.update({ - width, - height, - camera, - start: startArrow ? start : end, - end: startArrow ? end : start, - shaftPixelWidth: this.parameters.shaftPixelWidth, - shaftPixelOffset: this.parameters.shaftPixelOffset, - arrowPixelSize: new Vector2(this.parameters.arrowPixelWidth, this.parameters.arrowPixelHeight), - labelPixelWidth: this.labelTextClientWidth, - color: this.parameters.color, - }); - } - if (this.arrowNeedsUpdate) { - this.arrowNeedsUpdate = false; - this.updateArrowLabel(renderer, camera); - this.updateArrow(); - } - } - - public updateArrowMaterial(startArrow: boolean, renderer: WebGLRenderer, camera: Camera, material: Material) { - this.updateMatrixWorld(); - if (material instanceof DimensioningArrowMaterial) { - const renderTarget = renderer.getRenderTarget(); - const width = renderTarget?.width ?? renderer.domElement.clientWidth; - const height = renderTarget?.height ?? renderer.domElement.clientHeight; - const start = this.startPosition.clone().applyMatrix4(this.matrixWorld); - const end = this.endPosition.clone().applyMatrix4(this.matrixWorld); - material.update({ - width, - height, - camera, - start: startArrow ? start : end, - end: startArrow ? end : start, - arrowPixelSize: new Vector2(this.parameters.arrowPixelWidth, this.parameters.arrowPixelHeight), - color: this.parameters.color, - }); - } - if (this.arrowNeedsUpdate) { - this.arrowNeedsUpdate = false; - this.updateArrowLabel(renderer, camera); - this.updateArrow(); - } + if (this.arrowNeedsUpdate) { + this.arrowNeedsUpdate = false; + this.updateArrowLabel(renderer, camera); + this.updateArrow(); } + } } -const glslShaftVertexShader = -`varying vec2 centerPixel; +const glslShaftVertexShader = `varying vec2 centerPixel; varying vec2 posPixel; varying vec2 arrowDir; @@ -268,8 +375,7 @@ void main() { arrowDir = clipDir; }`; -const glslShaftFragmentShader = -`varying vec2 centerPixel; +const glslShaftFragmentShader = `varying vec2 centerPixel; varying vec2 posPixel; varying vec2 arrowDir; @@ -283,69 +389,70 @@ void main() { }`; export class DimensioningArrowShaftMaterial extends ShaderMaterial { - private static shader: any = { - uniforms: { - resolution: { value: new Vector2() }, - start: { value: new Vector3() }, - end: { value: new Vector3() }, - shaftPixelWidth: { value: 10.0 }, - shaftPixelOffset: { value: 10.0 }, - arrowPixelSize: { value: new Vector2() }, - labelPixelWidth: { value: 0 }, - color: { value: new Color() }, - }, - defines: { - RADIUS_RATIO: 0.5, - }, - vertexShader: glslShaftVertexShader, - fragmentShader: glslShaftFragmentShader, - }; - - constructor(parameters?: any) { - super({ - defines: Object.assign({}, DimensioningArrowShaftMaterial.shader.defines), - uniforms: UniformsUtils.clone(DimensioningArrowShaftMaterial.shader.uniforms), - vertexShader: DimensioningArrowShaftMaterial.shader.vertexShader, - fragmentShader: DimensioningArrowShaftMaterial.shader.fragmentShader, - side: DoubleSide, - blending: NoBlending, - }); - this.update(parameters); + private static shader: any = { + uniforms: { + resolution: { value: new Vector2() }, + start: { value: new Vector3() }, + end: { value: new Vector3() }, + shaftPixelWidth: { value: 10.0 }, + shaftPixelOffset: { value: 10.0 }, + arrowPixelSize: { value: new Vector2() }, + labelPixelWidth: { value: 0 }, + color: { value: new Color() }, + }, + defines: { + RADIUS_RATIO: 0.5, + }, + vertexShader: glslShaftVertexShader, + fragmentShader: glslShaftFragmentShader, + }; + + constructor(parameters?: any) { + super({ + defines: Object.assign({}, DimensioningArrowShaftMaterial.shader.defines), + uniforms: UniformsUtils.clone( + DimensioningArrowShaftMaterial.shader.uniforms + ), + vertexShader: DimensioningArrowShaftMaterial.shader.vertexShader, + fragmentShader: DimensioningArrowShaftMaterial.shader.fragmentShader, + side: DoubleSide, + blending: NoBlending, + }); + this.update(parameters); + } + + public update(parameters?: any): DimensioningArrowShaftMaterial { + if (parameters?.width || parameters?.height) { + const width = parameters?.width ?? this.uniforms.resolution.value.x; + const height = parameters?.height ?? this.uniforms.resolution.value.y; + this.uniforms.resolution.value.set(width, height); } - - public update(parameters?: any): DimensioningArrowShaftMaterial { - if (parameters?.width || parameters?.height) { - const width = parameters?.width ?? this.uniforms.resolution.value.x; - const height = parameters?.height ?? this.uniforms.resolution.value.y; - this.uniforms.resolution.value.set(width, height); - } - if (parameters?.start !== undefined) { - this.uniforms.start.value.copy(parameters.start); - } - if (parameters?.end !== undefined) { - this.uniforms.end.value.copy(parameters.end); - } - if (parameters?.shaftPixelWidth !== undefined) { - this.uniforms.shaftPixelWidth.value = parameters.shaftPixelWidth; - } - if (parameters?.shaftPixelOffset !== undefined) { - this.uniforms.shaftPixelOffset.value = parameters.shaftPixelOffset; - } - if (parameters?.arrowPixelSize !== undefined) { - this.uniforms.arrowPixelSize.value.copy(parameters.arrowPixelSize); - } - if (parameters?.labelPixelWidth !== undefined) { - this.uniforms.labelPixelWidth.value = parameters.labelPixelWidth; - } - if (parameters?.color !== undefined) { - this.uniforms.color.value = new Color(parameters.color); - } - return this; + if (parameters?.start !== undefined) { + this.uniforms.start.value.copy(parameters.start); + } + if (parameters?.end !== undefined) { + this.uniforms.end.value.copy(parameters.end); + } + if (parameters?.shaftPixelWidth !== undefined) { + this.uniforms.shaftPixelWidth.value = parameters.shaftPixelWidth; + } + if (parameters?.shaftPixelOffset !== undefined) { + this.uniforms.shaftPixelOffset.value = parameters.shaftPixelOffset; + } + if (parameters?.arrowPixelSize !== undefined) { + this.uniforms.arrowPixelSize.value.copy(parameters.arrowPixelSize); } + if (parameters?.labelPixelWidth !== undefined) { + this.uniforms.labelPixelWidth.value = parameters.labelPixelWidth; + } + if (parameters?.color !== undefined) { + this.uniforms.color.value = new Color(parameters.color); + } + return this; + } } -const glslArrowVertexShader = -`varying vec2 arrowUv; +const glslArrowVertexShader = `varying vec2 arrowUv; varying vec2 centerPixel; varying vec2 posPixel; @@ -375,8 +482,7 @@ void main() { posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution; }`; -const glslArrowFragmentShader = -`varying vec2 arrowUv; +const glslArrowFragmentShader = `varying vec2 arrowUv; varying vec2 centerPixel; varying vec2 posPixel; @@ -393,51 +499,51 @@ void main() { }`; export class DimensioningArrowMaterial extends ShaderMaterial { - private static shader: any = { - uniforms: { - resolution: { value: new Vector2() }, - start: { value: new Vector3() }, - end: { value: new Vector3() }, - arrowPixelSize: { value: new Vector2() }, - color: { value: new Color() }, - }, - defines: { - RADIUS_RATIO: 0.5, - }, - vertexShader: glslArrowVertexShader, - fragmentShader: glslArrowFragmentShader, - }; - - constructor(parameters?: any) { - super({ - defines: Object.assign({}, DimensioningArrowMaterial.shader.defines), - uniforms: UniformsUtils.clone(DimensioningArrowMaterial.shader.uniforms), - vertexShader: DimensioningArrowMaterial.shader.vertexShader, - fragmentShader: DimensioningArrowMaterial.shader.fragmentShader, - side: DoubleSide, - blending: NoBlending, - }); - this.update(parameters); + private static shader: any = { + uniforms: { + resolution: { value: new Vector2() }, + start: { value: new Vector3() }, + end: { value: new Vector3() }, + arrowPixelSize: { value: new Vector2() }, + color: { value: new Color() }, + }, + defines: { + RADIUS_RATIO: 0.5, + }, + vertexShader: glslArrowVertexShader, + fragmentShader: glslArrowFragmentShader, + }; + + constructor(parameters?: any) { + super({ + defines: Object.assign({}, DimensioningArrowMaterial.shader.defines), + uniforms: UniformsUtils.clone(DimensioningArrowMaterial.shader.uniforms), + vertexShader: DimensioningArrowMaterial.shader.vertexShader, + fragmentShader: DimensioningArrowMaterial.shader.fragmentShader, + side: DoubleSide, + blending: NoBlending, + }); + this.update(parameters); + } + + public update(parameters?: any): DimensioningArrowMaterial { + if (parameters?.width || parameters?.height) { + const width = parameters?.width ?? this.uniforms.resolution.value.x; + const height = parameters?.height ?? this.uniforms.resolution.value.y; + this.uniforms.resolution.value.set(width, height); } - - public update(parameters?: any): DimensioningArrowMaterial { - if (parameters?.width || parameters?.height) { - const width = parameters?.width ?? this.uniforms.resolution.value.x; - const height = parameters?.height ?? this.uniforms.resolution.value.y; - this.uniforms.resolution.value.set(width, height); - } - if (parameters?.start !== undefined) { - this.uniforms.start.value.copy(parameters.start); - } - if (parameters?.end !== undefined) { - this.uniforms.end.value.copy(parameters.end); - } - if (parameters?.arrowPixelSize !== undefined) { - this.uniforms.arrowPixelSize.value.copy(parameters.arrowPixelSize); - } - if (parameters?.color !== undefined) { - this.uniforms.color.value = new Color(parameters.color); - } - return this; + if (parameters?.start !== undefined) { + this.uniforms.start.value.copy(parameters.start); + } + if (parameters?.end !== undefined) { + this.uniforms.end.value.copy(parameters.end); + } + if (parameters?.arrowPixelSize !== undefined) { + this.uniforms.arrowPixelSize.value.copy(parameters.arrowPixelSize); + } + if (parameters?.color !== undefined) { + this.uniforms.color.value = new Color(parameters.color); } + return this; + } } diff --git a/src/client/scene/lightSources.ts b/src/client/scene/lightSources.ts index ec75408..a4731e2 100644 --- a/src/client/scene/lightSources.ts +++ b/src/client/scene/lightSources.ts @@ -1,256 +1,327 @@ -import { SceneRenderer } from '../renderer/scene-renderer' -import { SceneVolume } from '../renderer/render-utility' +import type { SceneRenderer } from '../renderer/scene-renderer'; +import type { SceneVolume } from '../renderer/render-utility'; +import type { ColorRepresentation, Light, Scene } from 'three'; import { - AmbientLight, - Color, - ColorRepresentation, - DirectionalLight, - Light, - OrthographicCamera, - PerspectiveCamera, - RectAreaLight, - Scene, - Vector3, + AmbientLight, + Color, + DirectionalLight, + RectAreaLight, + Vector3, } from 'three'; -import { GUI } from 'dat.gui'; +import type { GUI } from 'dat.gui'; export class LightSources { - public static noLightSources = []; - public static defaultLightSources = [ - { - type: 'ambient', - color: '#ffffff' - }, - { - type: 'rectArea', - position: { x: 0, y: 5, z: 3 }, - color: '#ffffff', - intensity: 60, - castShadow: true, - }, - { - type: 'rectArea', - position: { x: -5, y: 3, z: 2 }, - color: '#ffffff', - intensity: 60, - castShadow: false, - } - ]; - public static fifeLightSources = [ - { - type: 'ambient', - color: '#ffffff' - }, - { - type: 'rectArea', - position: { x: 0, y: 5, z: 0 }, - color: '#ffffff', - intensity: 40, - castShadow: true, - }, - { - type: 'rectArea', - position: { x: 5, y: 5, z: 5 }, - color: '#ffffff', - intensity: 60, - castShadow: true, - }, - { - type: 'rectArea', - position: { x: -5, y: 5, z: 5 }, - color: '#ffffff', - intensity: 60, - castShadow: true, - }, - { - type: 'rectArea', - position: { x: 5, y: 5, z: -5 }, - color: '#ffffff', - intensity: 60, - castShadow: true, - }, - { - type: 'rectArea', - position: { x: -5, y: 5, z: -5 }, - color: '#ffffff', - intensity: 60, - castShadow: true, - }, - ]; + public static noLightSources = []; + public static defaultLightSources = [ + { + type: 'ambient', + color: '#ffffff', + }, + { + type: 'rectArea', + position: { x: 0, y: 5, z: 3 }, + color: '#ffffff', + intensity: 60, + castShadow: true, + }, + { + type: 'rectArea', + position: { x: -5, y: 3, z: 2 }, + color: '#ffffff', + intensity: 60, + castShadow: false, + }, + ]; + public static fifeLightSources = [ + { + type: 'ambient', + color: '#ffffff', + }, + { + type: 'rectArea', + position: { x: 0, y: 5, z: 0 }, + color: '#ffffff', + intensity: 40, + castShadow: true, + }, + { + type: 'rectArea', + position: { x: 5, y: 5, z: 5 }, + color: '#ffffff', + intensity: 60, + castShadow: true, + }, + { + type: 'rectArea', + position: { x: -5, y: 5, z: 5 }, + color: '#ffffff', + intensity: 60, + castShadow: true, + }, + { + type: 'rectArea', + position: { x: 5, y: 5, z: -5 }, + color: '#ffffff', + intensity: 60, + castShadow: true, + }, + { + type: 'rectArea', + position: { x: -5, y: 5, z: -5 }, + color: '#ffffff', + intensity: 60, + castShadow: true, + }, + ]; - public lightControls: boolean = false; - private _scene: Scene - private _lightSources: Light[] = []; - private _useRectAreaLight: boolean = true; - public sceneRenderer: SceneRenderer | undefined; - private lightSourceScale?: number; - public currentLightSourceDefinition: any[] = LightSources.defaultLightSources; + public lightControls: boolean = false; + private _scene: Scene; + private _lightSources: Light[] = []; + private _useRectAreaLight: boolean = true; + public sceneRenderer: SceneRenderer | undefined; + private lightSourceScale?: number; + public currentLightSourceDefinition: any[] = LightSources.defaultLightSources; - get useRectAreaLight() { - return this._useRectAreaLight; - } + get useRectAreaLight() { + return this._useRectAreaLight; + } - constructor(scene: Scene, sceneRenderer: SceneRenderer, width: number, height: number, samples: number, parameters?: any) { - this._scene = scene - this.sceneRenderer = sceneRenderer; - this.updateLightSources(); - } + constructor( + scene: Scene, + sceneRenderer: SceneRenderer, + _width: number, + _height: number, + _samples: number, + _parameters?: any + ) { + this._scene = scene; + this.sceneRenderer = sceneRenderer; + this.updateLightSources(); + } - public updateLightSources() { - this.removeFromScene(); - this._lightSources = []; - this.readLightSources(this._scene, this.currentLightSourceDefinition); - this.addToScene(); - } + public updateLightSources() { + this.removeFromScene(); + this._lightSources = []; + this.readLightSources(this._scene, this.currentLightSourceDefinition); + this.addToScene(); + } - private readLightSources(scene: Scene, lightSourceDefinitions: any[]) { - const rectAreaLights: RectAreaLight[] = []; - lightSourceDefinitions.forEach(definition => { - switch (definition.type) { - default: break; - case 'ambient': - const ambientLight = new AmbientLight(new Color(definition.color), 0.0); - this._lightSources.push(ambientLight); - break; - case 'rectArea': - const position = new Vector3(definition.position.x, definition.position.y, definition.position.z); - if (this.lightSourceScale && position.length() < this.lightSourceScale) { - position.normalize().multiplyScalar(this.lightSourceScale); - } - if (this._useRectAreaLight) { - const rectAreaLightWidth = 0.8; - const rectAreaLightHeight = 0.8; - const intensity = (definition.intensity ?? 100) / (rectAreaLightWidth * rectAreaLightHeight); - const rectAreaLight = new RectAreaLight(new Color(definition.color), intensity, rectAreaLightWidth, rectAreaLightHeight); - rectAreaLight.position.copy(position); - rectAreaLight.matrixAutoUpdate = true; - rectAreaLight.visible = definition.castShadow; - rectAreaLight.lookAt(new Vector3(0, 0, 0)); - this._lightSources.push(rectAreaLight); - rectAreaLights.push(rectAreaLight); - } else { - const directionalLight = new DirectionalLight(new Color(definition.color), definition.intensity); - directionalLight.position.copy(position); - directionalLight.visible = true; - directionalLight.intensity = definition.intensity; - directionalLight.castShadow = definition.castShadow; - directionalLight.lookAt(new Vector3(0, 0, 0)); - this._lightSources.push(directionalLight); - } - break; + private readLightSources(scene: Scene, lightSourceDefinitions: any[]) { + const rectAreaLights: RectAreaLight[] = []; + lightSourceDefinitions.forEach((definition) => { + switch (definition.type) { + default: + break; + case 'ambient': + { + const ambientLight = new AmbientLight( + new Color(definition.color), + 0.0 + ); + this._lightSources.push(ambientLight); + } + break; + case 'rectArea': + { + const position = new Vector3( + definition.position.x, + definition.position.y, + definition.position.z + ); + if ( + this.lightSourceScale && + position.length() < this.lightSourceScale + ) { + position.normalize().multiplyScalar(this.lightSourceScale); } - }); - this.sceneRenderer?.updateRectAreaLights(rectAreaLights, scene); - } + if (this._useRectAreaLight) { + const rectAreaLightWidth = 0.8; + const rectAreaLightHeight = 0.8; + const intensity = + (definition.intensity ?? 100) / + (rectAreaLightWidth * rectAreaLightHeight); + const rectAreaLight = new RectAreaLight( + new Color(definition.color), + intensity, + rectAreaLightWidth, + rectAreaLightHeight + ); + rectAreaLight.position.copy(position); + rectAreaLight.matrixAutoUpdate = true; + rectAreaLight.visible = definition.castShadow; + rectAreaLight.lookAt(new Vector3(0, 0, 0)); + this._lightSources.push(rectAreaLight); + rectAreaLights.push(rectAreaLight); + } else { + const directionalLight = new DirectionalLight( + new Color(definition.color), + definition.intensity + ); + directionalLight.position.copy(position); + directionalLight.visible = true; + directionalLight.intensity = definition.intensity; + directionalLight.castShadow = definition.castShadow; + directionalLight.lookAt(new Vector3(0, 0, 0)); + this._lightSources.push(directionalLight); + } + } + break; + } + }); + this.sceneRenderer?.updateRectAreaLights(rectAreaLights, scene); + } - public getLightSources(): Light[] { - return this._lightSources; - } + public getLightSources(): Light[] { + return this._lightSources; + } - public getShadowLightSources(): Light[] { - const shadowLightSources: Light[] = []; - for (let i = 0; i < this._lightSources.length; i++) { - const light = this._lightSources[i]; - if (light instanceof AmbientLight) { - continue; - } - shadowLightSources.push(this.sceneRenderer?.screenSpaceShadow.findShadowLightSource(light) || light); - } - return shadowLightSources; + public getShadowLightSources(): Light[] { + const shadowLightSources: Light[] = []; + for (const light of this._lightSources) { + if (light instanceof AmbientLight) { + continue; + } + shadowLightSources.push( + this.sceneRenderer?.screenSpaceShadow.findShadowLightSource(light) || + light + ); } + return shadowLightSources; + } - public setLightSourcesDistances(sceneVolume: SceneVolume, scaleDistance: boolean) { - this.lightSourceScale = scaleDistance ? sceneVolume.maxSceneDistanceFrom0 * 1.5 : undefined; - this.updateLightSources(); - } + public setLightSourcesDistances( + sceneVolume: SceneVolume, + scaleDistance: boolean + ) { + this.lightSourceScale = scaleDistance + ? sceneVolume.maxSceneDistanceFrom0 * 1.5 + : undefined; + this.updateLightSources(); + } - public addToScene(): void { - this._lightSources.forEach(light => this._scene.add(light)); - } + public addToScene(): void { + this._lightSources.forEach((light) => this._scene.add(light)); + } - public removeFromScene(): void { - this._lightSources.forEach(light => this._scene.remove(light)); - } + public removeFromScene(): void { + this._lightSources.forEach((light) => this._scene.remove(light)); + } - public reload(): void { - this.removeFromScene(); - this.addToScene(); - } + public reload(): void { + this.removeFromScene(); + this.addToScene(); + } } export class LightSourcesGUI { - private lightSources: LightSources; - private lightColors: any = []; - private lightGUI: GUI | undefined; - private lightSourceFolders: GUI[] = []; - private lights: string = 'none'; + private lightSources: LightSources; + private lightColors: any = []; + private lightGUI: GUI | undefined; + private lightSourceFolders: GUI[] = []; + private lights: string = 'none'; - constructor(lightSources: LightSources) { - this.lightSources = lightSources; - } + constructor(lightSources: LightSources) { + this.lightSources = lightSources; + } - public addGUI(gui: GUI, lightControlsUpdate: () => void, lightSourcesUpdate: () => void): void { - gui.add(this.lightSources, 'lightControls').onChange(lightControlsUpdate); - gui.add(this, 'lights', ['none', 'default', 'fife']).onChange((value: string) => { - switch (value) { - default: - case 'none': this.lightSources.currentLightSourceDefinition = LightSources.noLightSources; break; - case 'default': this.lightSources.currentLightSourceDefinition = LightSources.defaultLightSources; break; - case 'fife': this.lightSources.currentLightSourceDefinition = LightSources.fifeLightSources; break; - }; - this.lightSources.updateLightSources(); - this.updateGUI(); - lightSourcesUpdate(); - }); - this.lightGUI = gui; + public addGUI( + gui: GUI, + lightControlsUpdate: () => void, + lightSourcesUpdate: () => void + ): void { + gui + .add(this.lightSources, 'lightControls') + .onChange(lightControlsUpdate); + gui + .add(this, 'lights', ['none', 'default', 'fife']) + .onChange((value: string) => { + switch (value) { + default: + case 'none': + this.lightSources.currentLightSourceDefinition = + LightSources.noLightSources; + break; + case 'default': + this.lightSources.currentLightSourceDefinition = + LightSources.defaultLightSources; + break; + case 'fife': + this.lightSources.currentLightSourceDefinition = + LightSources.fifeLightSources; + break; + } + this.lightSources.updateLightSources(); this.updateGUI(); - } + lightSourcesUpdate(); + }); + this.lightGUI = gui; + this.updateGUI(); + } - public updateGUI(): void { - if (!this.lightGUI) { - return; - } - const gui: GUI = this.lightGUI; - this.lightSourceFolders.forEach(folder => gui.removeFolder(folder)); - this.lightSourceFolders = []; - this.lightColors = []; - this.lightSources.getLightSources().forEach(light => { - if (light instanceof AmbientLight) { - this.lightColors.push({ - color: light.color.getHex() - }); - const ambiLight = gui.addFolder('Ambient Light'); - this.lightSourceFolders.push(ambiLight); - ambiLight.add(light, 'visible'); - ambiLight.add(light, 'intensity').min(0).max(5).step(0.1); - ambiLight.addColor(this.lightColors[this.lightColors.length-1], 'color').onChange((color: ColorRepresentation) => light.color = new Color(color)); - } + public updateGUI(): void { + if (!this.lightGUI) { + return; + } + const gui: GUI = this.lightGUI; + this.lightSourceFolders.forEach((folder) => gui.removeFolder(folder)); + this.lightSourceFolders = []; + this.lightColors = []; + this.lightSources.getLightSources().forEach((light) => { + if (light instanceof AmbientLight) { + this.lightColors.push({ + color: light.color.getHex(), }); - this.lightSources.getLightSources().forEach(light => { - if (light instanceof DirectionalLight) { - this.lightColors.push({ - color: light.color.getHex() - }); - const lightFolder = gui.addFolder(`Directional Light ${this.lightColors.length-1}`); - this.lightSourceFolders.push(lightFolder); - lightFolder.add(light, 'visible'); - lightFolder.add(light, 'intensity').min(0).max(10).step(0.1); - lightFolder.add(light, 'castShadow'); - lightFolder.addColor(this.lightColors[this.lightColors.length-1], 'color').onChange((color: ColorRepresentation) => light.color = new Color(color)); - } else if (light instanceof RectAreaLight) { - this.lightColors.push({ - color: light.color.getHex() - }); - const lightFolder = gui.addFolder(`Rect area Light ${this.lightColors.length-1}`); - this.lightSourceFolders.push(lightFolder); - const shadowLight = this.lightSources.sceneRenderer?.screenSpaceShadow.findShadowLightSource(light); - lightFolder.add(light, 'visible'); - lightFolder.add(light, 'intensity').min(0).max(200).step(1); - if (shadowLight) { - lightFolder.add(shadowLight, 'castShadow'); - } - lightFolder.addColor(this.lightColors[this.lightColors.length-1], 'color').onChange((color: ColorRepresentation) => light.color = new Color(color)); - } + const ambiLight = gui.addFolder('Ambient Light'); + this.lightSourceFolders.push(ambiLight); + ambiLight.add(light, 'visible'); + ambiLight.add(light, 'intensity').min(0).max(5).step(0.1); + ambiLight + .addColor(this.lightColors[this.lightColors.length - 1], 'color') + .onChange( + (color: ColorRepresentation) => (light.color = new Color(color)) + ); + } + }); + this.lightSources.getLightSources().forEach((light) => { + if (light instanceof DirectionalLight) { + this.lightColors.push({ + color: light.color.getHex(), }); - } -} \ No newline at end of file + const lightFolder = gui.addFolder( + `Directional Light ${this.lightColors.length - 1}` + ); + this.lightSourceFolders.push(lightFolder); + lightFolder.add(light, 'visible'); + lightFolder.add(light, 'intensity').min(0).max(10).step(0.1); + lightFolder.add(light, 'castShadow'); + lightFolder + .addColor(this.lightColors[this.lightColors.length - 1], 'color') + .onChange( + (color: ColorRepresentation) => (light.color = new Color(color)) + ); + } else if (light instanceof RectAreaLight) { + this.lightColors.push({ + color: light.color.getHex(), + }); + const lightFolder = gui.addFolder( + `Rect area Light ${this.lightColors.length - 1}` + ); + this.lightSourceFolders.push(lightFolder); + const shadowLight = + this.lightSources.sceneRenderer?.screenSpaceShadow.findShadowLightSource( + light + ); + lightFolder.add(light, 'visible'); + lightFolder.add(light, 'intensity').min(0).max(200).step(1); + if (shadowLight) { + lightFolder.add(shadowLight, 'castShadow'); + } + lightFolder + .addColor(this.lightColors[this.lightColors.length - 1], 'color') + .onChange( + (color: ColorRepresentation) => (light.color = new Color(color)) + ); + } + }); + } +} diff --git a/src/client/scene/material-gui.ts b/src/client/scene/material-gui.ts index 94ef40a..2306e3a 100644 --- a/src/client/scene/material-gui.ts +++ b/src/client/scene/material-gui.ts @@ -1,107 +1,134 @@ -import { Color, MeshPhysicalMaterial } from 'three'; -import { MaterialData } from './meshConstructor'; -import { GUI } from 'dat.gui'; +import type { Color, MeshPhysicalMaterial } from 'three'; +import type { MaterialData } from './meshConstructor'; +import type { GUI } from 'dat.gui'; export class MaterialGUI { - private materials: MaterialData[] = []; - private materialFolder: GUI | undefined; - private materialProperties: GUI | undefined; - private materialId: string = ''; + private materials: MaterialData[] = []; + private materialFolder: GUI | undefined; + private materialProperties: GUI | undefined; + private materialId: string = ''; - public updateMaterialUI(gui: GUI, materialsData: MaterialData[]) { - if (this.materialFolder) { - gui.removeFolder(this.materialFolder) - this.materialProperties = undefined; - } - this.materialFolder = gui.addFolder('Materials'); - this.materials = materialsData; - this. materialId = materialsData[0]?.materialId ?? ''; - const materialNames = materialsData.map(item => { - let name: string = item.materialId; - return { 'materialId': item.materialId, 'name': name }; - }) - let parameterMenuItems = Object.assign({}, ...materialNames.map((item) => ({[item.name]: item.materialId}))); - this.materialFolder.add(this, 'materialId', parameterMenuItems).onChange((value) => this.updateMaterialPropertiesUI(value)); - this.updateMaterialPropertiesUI(this.materialId); + public updateMaterialUI(gui: GUI, materialsData: MaterialData[]) { + if (this.materialFolder) { + gui.removeFolder(this.materialFolder); + this.materialProperties = undefined; } + this.materialFolder = gui.addFolder('Materials'); + this.materials = materialsData; + this.materialId = materialsData[0]?.materialId ?? ''; + const materialNames = materialsData.map((item) => { + const name: string = item.materialId; + return { materialId: item.materialId, name }; + }); + const parameterMenuItems = Object.assign( + {}, + ...materialNames.map((item) => ({ [item.name]: item.materialId })) + ); + this.materialFolder + .add(this, 'materialId', parameterMenuItems) + .onChange((value) => this.updateMaterialPropertiesUI(value)); + this.updateMaterialPropertiesUI(this.materialId); + } - private updateMaterialPropertiesUI(materialId: string) { - this.materialId = materialId; - if (!this.materialFolder) { - return; - } - if (this.materialProperties) { - this.materialFolder.removeFolder(this.materialProperties); - this.materialProperties = undefined; - } - const materialData = this.materials.find(item => item.materialId === materialId); - if (!materialData) { - return; - } - const material = materialData.material as MeshPhysicalMaterial; - if (!material) { - return; - } - const uiMaterialData = { - color: material.color?.getHex() ?? 0xffffff, - specularColor: material.color?.getHex() ?? 0xffffff, - emissive: material.emissive?.getHex() ?? 0xffffff, - sheenColor: material.emissive?.getHex() ?? 0xffffff, - attenuationColor: material.emissive?.getHex() ?? 0xffffff - }; - let folderName = 'properties'; - if (materialData.material.userData) { - if (materialData.material.userData.diffuseMap) { - folderName += materialData.material.userData.diffuseMapHasAlpha ? ' RGBA' : ' RGB'; - } - if (materialData.material.userData.normalMap) { - folderName += ' XYZ'; - } - if (materialData.material.userData.ormMap) { - folderName += ' ORM'; - } - } - this.materialProperties = this.materialFolder.addFolder(folderName); - this.materialProperties.addColor(uiMaterialData, 'color').onChange(MaterialGUI.handleColorChange(material.color, true)); - this.materialProperties.add(material, 'opacity', 0, 1).onChange((value: number) => { - const transparent = value < 1; - if (transparent !== material.transparent) { - material.transparent = transparent; - material.needsUpdate = true; - } - }); - try { - this.materialProperties.add(material, 'metalness', 0, 1); - this.materialProperties.add(material, 'roughness', 0, 1); - this.materialProperties.add(material, 'transmission', 0, 1); - this.materialProperties.add(material, 'ior', 1, 2.333); - this.materialProperties.add(material, 'specularIntensity', 0, 1); - this.materialProperties.addColor(uiMaterialData, 'specularColor').onChange(MaterialGUI.handleColorChange(material.specularColor, true)); - this.materialProperties.add(material, 'reflectivity', 0, 1); - this.materialProperties.add(material, 'clearcoat', 0, 1); - this.materialProperties.add(material, 'clearcoatRoughness', 0, 1.0); - this.materialProperties.add(material, 'sheen', 0, 1.0); - this.materialProperties.add(material, 'sheenRoughness', 0, 1); - this.materialProperties.addColor(uiMaterialData, 'sheenColor').onChange(MaterialGUI.handleColorChange(material.sheenColor, true)); - this.materialProperties.add(material, 'emissiveIntensity', 0, 1); - this.materialProperties.addColor(uiMaterialData, 'emissive').onChange(MaterialGUI.handleColorChange(material.emissive, true)); - this.materialProperties.add(material, 'attenuationDistance', 0, 50); - this.materialProperties.addColor(uiMaterialData, 'attenuationColor').onChange(MaterialGUI.handleColorChange(material.attenuationColor, true)); - this.materialProperties.add(material, 'thickness', 0, 50); - } catch (e) { - console.log(e); - } + // eslint-disable-next-line complexity + private updateMaterialPropertiesUI(materialId: string) { + this.materialId = materialId; + if (!this.materialFolder) { + return; } - - private static handleColorChange(color: Color, converSRGBToLinear: boolean = false) { - return (value: any) => { - if (typeof value === 'string') { - value = value.replace('#', '0x'); - } - color.setHex(value) - if (converSRGBToLinear === true) { - color.convertSRGBToLinear() - } + if (this.materialProperties) { + this.materialFolder.removeFolder(this.materialProperties); + this.materialProperties = undefined; + } + const materialData = this.materials.find( + (item) => item.materialId === materialId + ); + if (!materialData) { + return; + } + const material = materialData.material as MeshPhysicalMaterial; + if (!material) { + return; + } + const uiMaterialData = { + color: material.color?.getHex() ?? 0xffffff, + specularColor: material.color?.getHex() ?? 0xffffff, + emissive: material.emissive?.getHex() ?? 0xffffff, + sheenColor: material.emissive?.getHex() ?? 0xffffff, + attenuationColor: material.emissive?.getHex() ?? 0xffffff, + }; + let folderName = 'properties'; + if (materialData.material.userData) { + if (materialData.material.userData.diffuseMap) { + folderName += materialData.material.userData.diffuseMapHasAlpha + ? ' RGBA' + : ' RGB'; + } + if (materialData.material.userData.normalMap) { + folderName += ' XYZ'; + } + if (materialData.material.userData.ormMap) { + folderName += ' ORM'; + } + } + this.materialProperties = this.materialFolder.addFolder(folderName); + this.materialProperties + .addColor(uiMaterialData, 'color') + .onChange(MaterialGUI.handleColorChange(material.color, true)); + this.materialProperties + .add(material, 'opacity', 0, 1) + .onChange((value: number) => { + const transparent = value < 1; + if (transparent !== material.transparent) { + material.transparent = transparent; + material.needsUpdate = true; } + }); + try { + this.materialProperties.add(material, 'metalness', 0, 1); + this.materialProperties.add(material, 'roughness', 0, 1); + this.materialProperties.add(material, 'transmission', 0, 1); + this.materialProperties.add(material, 'ior', 1, 2.333); + this.materialProperties.add(material, 'specularIntensity', 0, 1); + this.materialProperties + .addColor(uiMaterialData, 'specularColor') + .onChange(MaterialGUI.handleColorChange(material.specularColor, true)); + this.materialProperties.add(material, 'reflectivity', 0, 1); + this.materialProperties.add(material, 'clearcoat', 0, 1); + this.materialProperties.add(material, 'clearcoatRoughness', 0, 1.0); + this.materialProperties.add(material, 'sheen', 0, 1.0); + this.materialProperties.add(material, 'sheenRoughness', 0, 1); + this.materialProperties + .addColor(uiMaterialData, 'sheenColor') + .onChange(MaterialGUI.handleColorChange(material.sheenColor, true)); + this.materialProperties.add(material, 'emissiveIntensity', 0, 1); + this.materialProperties + .addColor(uiMaterialData, 'emissive') + .onChange(MaterialGUI.handleColorChange(material.emissive, true)); + this.materialProperties.add(material, 'attenuationDistance', 0, 50); + this.materialProperties + .addColor(uiMaterialData, 'attenuationColor') + .onChange( + MaterialGUI.handleColorChange(material.attenuationColor, true) + ); + this.materialProperties.add(material, 'thickness', 0, 50); + } catch (e) { + console.log(e); } -} \ No newline at end of file + } + + private static handleColorChange( + color: Color, + converSRGBToLinear: boolean = false + ) { + return (value: any) => { + if (typeof value === 'string') { + value = value.replace('#', '0x'); + } + color.setHex(value); + if (converSRGBToLinear === true) { + color.convertSRGBToLinear(); + } + }; + } +} diff --git a/src/client/scene/materials.ts b/src/client/scene/materials.ts index 17ec91e..afaf46a 100644 --- a/src/client/scene/materials.ts +++ b/src/client/scene/materials.ts @@ -1,91 +1,125 @@ -import { loadAndSetTexture } from '../renderer/render-utility' +import { loadAndSetTexture } from '../renderer/render-utility'; +import type { Material, Texture } from 'three'; import { - Color, - DoubleSide, - Material, - MeshPhysicalMaterial, - MeshStandardMaterial, - RepeatWrapping, - ShadowMaterial, - Texture, -} from 'three' + Color, + DoubleSide, + MeshPhysicalMaterial, + MeshStandardMaterial, + RepeatWrapping, + ShadowMaterial, +} from 'three'; // @ts-ignore -import LogoSquareImage from './../../../resources/rabbid.png' +import LogoSquareImage from './../../../resources/rabbid.png'; export const createPreviewMaterial = (): Material => { - const material = new MeshStandardMaterial({side: DoubleSide}) - loadAndSetTexture(texture => material.map = texture, LogoSquareImage, new Color(0.9, 0.9, 0.9)) - return material -} + const material = new MeshStandardMaterial({ side: DoubleSide }); + loadAndSetTexture( + (texture) => (material.map = texture), + LogoSquareImage, + new Color(0.9, 0.9, 0.9) + ); + return material; +}; export const enum GroundMaterialType { - OnlyShadow, - Transparent, - White, - Parquet, - Pavement + OnlyShadow, + Transparent, + White, + Parquet, + Pavement, } -const groundMaterialCache: any = {} -export const createGroundMaterial = (materialType: GroundMaterialType): Material => { - let material: Material = groundMaterialCache[materialType] - if (!material) { - switch(materialType) { - default: { - material = new MeshStandardMaterial() - break - } - case GroundMaterialType.OnlyShadow: { - material = new ShadowMaterial() - material.opacity = 0.5 - break - } - case GroundMaterialType.Transparent: { - material = new MeshStandardMaterial() - material.transparent = true; - material.opacity = 0 - break - } - case GroundMaterialType.White: { - material = new MeshStandardMaterial() - break - } - case GroundMaterialType.Parquet: { - const groundMaterial = new MeshPhysicalMaterial() - loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.map = texture }, 'TexturesCom_Wood_ParquetChevron7_1K_albedo.jpg', new Color(1.0, 0.6, 0.2)) - loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.normalMap = texture }, 'TexturesCom_Wood_ParquetChevron7_1K_normal.jpg') - loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.roughnessMap = texture }, 'TexturesCom_Wood_ParquetChevron7_1K_roughness.jpg') - groundMaterial.aoMapIntensity = 0 - groundMaterial.roughness = 1 - groundMaterial.metalness = 0 - groundMaterial.envMapIntensity = 0.5 - material = groundMaterial - break; - } - case GroundMaterialType.Pavement: { - const groundMaterial = new MeshPhysicalMaterial() - loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.map = texture }, 'TexturesCom_Pavement_HerringboneNew_1K_albedo.jpg', new Color(0.6, 0.3, 0)) - loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.normalMap = texture }, 'TexturesCom_Pavement_HerringboneNew_1K_normal.jpg') - loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.roughnessMap = texture }, 'TexturesCom_Pavement_HerringboneNew_1K_roughness.jpg') - loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.aoMap = texture }, 'TexturesCom_Pavement_HerringboneNew_1K_ao.jpg') - //loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.displacementMap = texture }, 'TexturesCom_Pavement_HerringboneNew_1K_height.jpg') - groundMaterial.aoMapIntensity = 1 - groundMaterial.roughness = 1 - groundMaterial.metalness = 0 - //groundMaterial.displacementScale = 1 - groundMaterial.envMapIntensity = 0.5 - material = groundMaterial - break; - } - } - groundMaterialCache[materialType] = material +const groundMaterialCache: any = {}; +export const createGroundMaterial = ( + materialType: GroundMaterialType +): Material => { + let material: Material = groundMaterialCache[materialType]; + if (!material) { + switch (materialType) { + default: { + material = new MeshStandardMaterial(); + break; + } + case GroundMaterialType.OnlyShadow: { + material = new ShadowMaterial(); + material.opacity = 0.5; + break; + } + case GroundMaterialType.Transparent: { + material = new MeshStandardMaterial(); + material.transparent = true; + material.opacity = 0; + break; + } + case GroundMaterialType.White: { + material = new MeshStandardMaterial(); + break; + } + case GroundMaterialType.Parquet: { + const groundMaterial = new MeshPhysicalMaterial(); + loadAndSetTexture( + (texture) => { + setTextureProperties(texture); + groundMaterial.map = texture; + }, + 'TexturesCom_Wood_ParquetChevron7_1K_albedo.jpg', + new Color(1.0, 0.6, 0.2) + ); + loadAndSetTexture((texture) => { + setTextureProperties(texture); + groundMaterial.normalMap = texture; + }, 'TexturesCom_Wood_ParquetChevron7_1K_normal.jpg'); + loadAndSetTexture((texture) => { + setTextureProperties(texture); + groundMaterial.roughnessMap = texture; + }, 'TexturesCom_Wood_ParquetChevron7_1K_roughness.jpg'); + groundMaterial.aoMapIntensity = 0; + groundMaterial.roughness = 1; + groundMaterial.metalness = 0; + groundMaterial.envMapIntensity = 0.5; + material = groundMaterial; + break; + } + case GroundMaterialType.Pavement: { + const groundMaterial = new MeshPhysicalMaterial(); + loadAndSetTexture( + (texture) => { + setTextureProperties(texture); + groundMaterial.map = texture; + }, + 'TexturesCom_Pavement_HerringboneNew_1K_albedo.jpg', + new Color(0.6, 0.3, 0) + ); + loadAndSetTexture((texture) => { + setTextureProperties(texture); + groundMaterial.normalMap = texture; + }, 'TexturesCom_Pavement_HerringboneNew_1K_normal.jpg'); + loadAndSetTexture((texture) => { + setTextureProperties(texture); + groundMaterial.roughnessMap = texture; + }, 'TexturesCom_Pavement_HerringboneNew_1K_roughness.jpg'); + loadAndSetTexture((texture) => { + setTextureProperties(texture); + groundMaterial.aoMap = texture; + }, 'TexturesCom_Pavement_HerringboneNew_1K_ao.jpg'); + //loadAndSetTexture(texture => { setTextureProperties(texture); groundMaterial.displacementMap = texture }, 'TexturesCom_Pavement_HerringboneNew_1K_height.jpg') + groundMaterial.aoMapIntensity = 1; + groundMaterial.roughness = 1; + groundMaterial.metalness = 0; + //groundMaterial.displacementScale = 1 + groundMaterial.envMapIntensity = 0.5; + material = groundMaterial; + break; + } } - return material -} + groundMaterialCache[materialType] = material; + } + return material; +}; const setTextureProperties = (texture: Texture): void => { - texture.anisotropy = 16; - texture.wrapS = RepeatWrapping; - texture.wrapT = RepeatWrapping; - texture.repeat.set(100000, 100000); -} \ No newline at end of file + texture.anisotropy = 16; + texture.wrapS = RepeatWrapping; + texture.wrapT = RepeatWrapping; + texture.repeat.set(100000, 100000); +}; diff --git a/src/client/scene/meshConstructor.ts b/src/client/scene/meshConstructor.ts index 59c24cb..110ea9f 100644 --- a/src/client/scene/meshConstructor.ts +++ b/src/client/scene/meshConstructor.ts @@ -1,34 +1,31 @@ -import { - BufferGeometry, - Group, - Material, - Matrix4, - Mesh, -} from 'three'; +import type { BufferGeometry, Material, Matrix4 } from 'three'; +import { Group, Mesh } from 'three'; export interface MaterialData { - materialId: string - material: Material + materialId: string; + material: Material; } export interface GeometryAndMaterial { - geometry: BufferGeometry, - material: Material, - transform?: Matrix4, - materialId: string, - environment: boolean + geometry: BufferGeometry; + material: Material; + transform?: Matrix4; + materialId: string; + environment: boolean; } -export const createSceneGroup = (geometryAndMaterial: GeometryAndMaterial[]) : Group => { - const sceneGroup = new Group(); - geometryAndMaterial.forEach(item => { - const mesh = new Mesh(item.geometry, item.material); - if (item.transform) { - mesh.applyMatrix4(item.transform); - } - mesh.castShadow = !item.environment; - mesh.receiveShadow = true; - sceneGroup.add(mesh); - }); - return sceneGroup; -} \ No newline at end of file +export const createSceneGroup = ( + geometryAndMaterial: GeometryAndMaterial[] +): Group => { + const sceneGroup = new Group(); + geometryAndMaterial.forEach((item) => { + const mesh = new Mesh(item.geometry, item.material); + if (item.transform) { + mesh.applyMatrix4(item.transform); + } + mesh.castShadow = !item.environment; + mesh.receiveShadow = true; + sceneGroup.add(mesh); + }); + return sceneGroup; +}; diff --git a/src/client/scene/postProcessingEffects.ts b/src/client/scene/postProcessingEffects.ts index 8313eee..eeb9892 100644 --- a/src/client/scene/postProcessingEffects.ts +++ b/src/client/scene/postProcessingEffects.ts @@ -1,160 +1,172 @@ -import { getMaxSamples } from '../renderer/render-utility' -import { - Camera, - FramebufferTexture, - RGBAFormat, - Scene, - Vector2, - WebGLRenderer, -} from 'three' -import { Pass } from 'three/examples/jsm/postprocessing/Pass'; -import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer' -import { SSRPass } from 'three/examples/jsm/postprocessing/SSRPass.js' +import { getMaxSamples } from '../renderer/render-utility'; +import type { Camera, Scene, WebGLRenderer } from 'three'; +import { FramebufferTexture, Vector2 } from 'three'; +import type { Pass } from 'three/examples/jsm/postprocessing/Pass'; +import type { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer'; +import { SSRPass } from 'three/examples/jsm/postprocessing/SSRPass.js'; import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass.js'; import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js'; import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader.js'; interface BloomParameters { - strength: number, - radius: number, - threshold: number + strength: number; + radius: number; + threshold: number; } class EffectPass { - public composer: EffectComposer - public pass: Pass - public enabled: boolean = false - public isEnabled: boolean = false - - constructor(composer: EffectComposer, pass: Pass) { - this.composer = composer - this.pass = pass - } - - public resize(width: number, height: number): void { - this.pass.setSize(width, height) - } - - public updateState(allowEnable: boolean) { - const enable = this.enabled && allowEnable - if (enable !== this.isEnabled) { - if (enable) { - this.composer.addPass(this.pass) - } else { - this.composer.removePass(this.pass) - } - this.isEnabled = enable - } + public composer: EffectComposer; + public pass: Pass; + public enabled: boolean = false; + public isEnabled: boolean = false; + + constructor(composer: EffectComposer, pass: Pass) { + this.composer = composer; + this.pass = pass; + } + + public resize(width: number, height: number): void { + this.pass.setSize(width, height); + } + + public updateState(allowEnable: boolean) { + const enable = this.enabled && allowEnable; + if (enable !== this.isEnabled) { + if (enable) { + this.composer.addPass(this.pass); + } else { + this.composer.removePass(this.pass); + } + this.isEnabled = enable; } + } } export class PostProcessingEffects { - private renderer: WebGLRenderer - private colorTexture: FramebufferTexture; - private width: number - private height: number - public composer: EffectComposer - public maxSamples: number - public outlinePassEnabled: boolean = false; - public ssrPass: EffectPass - public bloomPass: EffectPass - public fxaaPass: EffectPass - public bloomParameter: BloomParameters = { - strength: 1.5, - radius: 0.4, - threshold: 0.85 + private renderer: WebGLRenderer; + private colorTexture: FramebufferTexture; + private width: number; + private height: number; + public composer: EffectComposer; + public maxSamples: number; + public outlinePassEnabled: boolean = false; + public ssrPass: EffectPass; + public bloomPass: EffectPass; + public fxaaPass: EffectPass; + public bloomParameter: BloomParameters = { + strength: 1.5, + radius: 0.4, + threshold: 0.85, + }; + + constructor( + renderer: WebGLRenderer, + composer: EffectComposer, + scene: Scene, + camera: Camera, + width: number, + height: number, + _parameters?: any + ) { + this.renderer = renderer; + this.width = width; + this.height = height; + this.maxSamples = getMaxSamples(renderer); + this.colorTexture = new FramebufferTexture(this.width, this.height); + this.composer = composer; + + const bloomPass = new UnrealBloomPass( + new Vector2(width, height), + this.bloomParameter.strength, + this.bloomParameter.radius, + this.bloomParameter.threshold + ); + this.bloomPass = new EffectPass(this.composer, bloomPass); + + this.ssrPass = new EffectPass( + this.composer, + new SSRPass({ + renderer, + scene, + camera, + width: innerWidth, + height: innerHeight, + groundReflector: null, + selects: null, + }) + ); + + const fxaaPass = new ShaderPass(FXAAShader); + this.fxaaPass = new EffectPass(this.composer, fxaaPass); + } + + public resize(width: number, height: number): void { + this.width = width; + this.height = height; + this.composer.setSize(width, height); + this.fxaaPass.resize(width, height); + this.ssrPass.resize(width, height); + this.bloomPass.resize(width, height); + this.colorTexture.dispose(); + this.colorTexture = new FramebufferTexture(this.width, this.height); + } + + public setFxaa(enabled: boolean) { + this.fxaaPass.enabled = enabled; + this.updateFxaa(); + if (this.fxaaPass.isEnabled) { + const pixelRatio = this.renderer.getPixelRatio(); + // @ts-ignore + this.fxaaPass.material.uniforms.resolution.value.x = + 1 / (this.width * pixelRatio); + // @ts-ignore + this.fxaaPass.material.uniforms.resolution.value.y = + 1 / (this.height * pixelRatio); } + } - constructor(renderer: WebGLRenderer, composer: EffectComposer, scene: Scene, camera: Camera, width: number, height: number, parameters?: any) { - this.renderer = renderer - this.width = width - this.height = height - this.maxSamples = getMaxSamples(renderer) - this.colorTexture = new FramebufferTexture(this.width, this.height); - this.composer = composer; - - const bloomPass = new UnrealBloomPass(new Vector2(width, height), this.bloomParameter.strength, this.bloomParameter.radius, this.bloomParameter.threshold); - this.bloomPass = new EffectPass(this.composer, bloomPass) - - this.ssrPass = new EffectPass(this.composer, new SSRPass({ - renderer, - scene, - camera, - width: innerWidth, - height: innerHeight, - groundReflector: null, - selects: null - })); - - const fxaaPass = new ShaderPass(FXAAShader) - this.fxaaPass = new EffectPass(this. composer, fxaaPass) - } + public setBloom(enabled: boolean) { + this.bloomPass.enabled = enabled; + this.updateBloom(); + } - public resize(width: number, height: number): void { - this.width = width - this.height = height - this.composer.setSize(width, height) - this.fxaaPass.resize(width, height) - this.ssrPass.resize(width, height) - this.bloomPass.resize(width, height) - this.colorTexture.dispose(); - this.colorTexture = new FramebufferTexture(this.width, this.height); + public setSSR(enabled: boolean) { + const bloomIsEnabled = this.bloomPass.isEnabled; + if (bloomIsEnabled) { + this.setBloom(false); } - - public setFxaa(enabled: boolean) { - this.fxaaPass.enabled = enabled - this.updateFxaa() - if (this.fxaaPass.isEnabled) { - const pixelRatio = this.renderer.getPixelRatio(); - // @ts-ignore - this.fxaaPass.material.uniforms['resolution'].value.x = 1 / (this.width * pixelRatio); - // @ts-ignore - this.fxaaPass.material.uniforms['resolution'].value.y = 1 / (this.height * pixelRatio); - } + this.ssrPass.enabled = enabled; + this.updateSSR(); + if (bloomIsEnabled) { + this.setBloom(true); } + } - public setBloom(enabled: boolean) { - this.bloomPass.enabled = enabled - this.updateBloom() - } + public anyPostProcess(): boolean { + return this.bloomPass.enabled || this.ssrPass.enabled; + } - public setSSR(enabled: boolean) { - const bloomIsEnabled = this.bloomPass.isEnabled - if (bloomIsEnabled) { - this.setBloom(false) - } - this.ssrPass.enabled = enabled - this.updateSSR() - if (bloomIsEnabled) { - this.setBloom(true) - } + public render(): void { + if (this.anyPostProcess()) { + this.composer.render(); } + } - public anyPostProcess(): boolean { - return this.bloomPass.enabled || this.ssrPass.enabled; - } + public setDebugEffect(_effect: string) { + this.updateFxaa(); + this.updateBloom(); + this.updateSSR(); + } - public render(): void { - if (this.anyPostProcess()) { - this.composer.render() - } - } - - public setDebugEffect(effect: string) { - this.updateFxaa() - this.updateBloom() - this.updateSSR() - } + private updateFxaa() { + this.fxaaPass.updateState(true); + } - private updateFxaa() { - this.fxaaPass.updateState(true) - } + private updateBloom() { + this.bloomPass.updateState(true); + } - private updateBloom() { - this.bloomPass.updateState(true) - } - - private updateSSR() { - this.ssrPass.updateState(true) - } + private updateSSR() { + this.ssrPass.updateState(true); + } } diff --git a/src/client/scene/quality-levels.ts b/src/client/scene/quality-levels.ts index 4d576b8..ffb4171 100644 --- a/src/client/scene/quality-levels.ts +++ b/src/client/scene/quality-levels.ts @@ -30,7 +30,7 @@ const shAndAoPassParameters = { shadowOnGround: true, aoIntensity: 1.0, shadowIntensity: 1.0, - ao : { + ao: { algorithm: AoAlgorithms.GTAO, samples: 16, radius: 0.5, @@ -40,7 +40,7 @@ const shAndAoPassParameters = { scale: 1, bias: 0.01, screenSpaceRadius: false, - } + }, }; const screenSpaceShadowMapParameters = { @@ -50,7 +50,7 @@ const screenSpaceShadowMapParameters = { groundBoundary: 0.0, fadeOutDistance: 0.2, fadeOutBlur: 5.0, -} +}; export const defaultQualityLevels: QualityMap = new Map([ [ @@ -111,4 +111,4 @@ export const defaultQualityLevels: QualityMap = new Map([ }, }, ], -]); \ No newline at end of file +]); diff --git a/src/client/scene/sceneManager.ts b/src/client/scene/sceneManager.ts index 430199f..d9b5916 100644 --- a/src/client/scene/sceneManager.ts +++ b/src/client/scene/sceneManager.ts @@ -1,8 +1,5 @@ -import { - createSceneGroup, - GeometryAndMaterial, - MaterialData -} from './meshConstructor' +import type { GeometryAndMaterial, MaterialData } from './meshConstructor'; +import { createSceneGroup } from './meshConstructor'; import { LightSources } from './lightSources'; import { createGroundMaterial, @@ -58,7 +55,7 @@ import type { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.j // @ts-ignore import { GroundProjectedSkybox } from 'three/examples/jsm/objects/GroundProjectedSkybox.js'; // @ts-ignore -import Test64EnvMap from './../../../resources/test64.envmap' +import Test64EnvMap from './../../../resources/test64.envmap'; export interface SceneProperties { rotate: number; @@ -447,7 +444,7 @@ export class SceneManager { this.turnTableGroup, true ); - let selectedObject = + const selectedObject = intersects.length > 0 ? intersects[0].object : undefined; this.sceneRenderer.selectObjects( selectedObject ? [selectedObject as Object3D] : [] @@ -645,4 +642,4 @@ export class SceneManager { } return createSceneGroup(loadingGeometry); } -} \ No newline at end of file +} diff --git a/src/client/scene/skyEnvironment.ts b/src/client/scene/skyEnvironment.ts index 2ae6548..bd54c04 100644 --- a/src/client/scene/skyEnvironment.ts +++ b/src/client/scene/skyEnvironment.ts @@ -1,67 +1,67 @@ -import { viewSpacePositionFromUV } from '../renderer/render-utility' -import { - Object3D, -} from 'three'; +import { viewSpacePositionFromUV } from '../renderer/render-utility'; +import type { Object3D } from 'three'; import { Sky } from 'three/examples/jsm/objects/Sky.js'; -import { GUI, GUIController } from 'dat.gui' +import type { GUI, GUIController } from 'dat.gui'; export interface SkyParameter { - [key: string]: any; - visible: boolean; - distance: number; - turbidity: number; - rayleigh: number; - mieCoefficient: number; - mieDirectionalG: number; - inclination: number; - azimuth: number; + [key: string]: any; + visible: boolean; + distance: number; + turbidity: number; + rayleigh: number; + mieCoefficient: number; + mieDirectionalG: number; + inclination: number; + azimuth: number; } export class SkyEnvironment { - public parameters: SkyParameter; - public sky: Sky; + public parameters: SkyParameter; + public sky: Sky; - constructor(parameters?: any) { - this.sky = new Sky(); - this.sky.name = 'Sky'; - this.parameters = { - visible: true, - distance: 400000, - turbidity: 10, - rayleigh: 2, - mieCoefficient: 0.005, - mieDirectionalG: 0.8, - inclination: 0.6, - azimuth: 0, - ...parameters, - }; - this.updateSky(); - } + constructor(parameters?: any) { + this.sky = new Sky(); + this.sky.name = 'Sky'; + this.parameters = { + visible: true, + distance: 400000, + turbidity: 10, + rayleigh: 2, + mieCoefficient: 0.005, + mieDirectionalG: 0.8, + inclination: 0.6, + azimuth: 0, + ...parameters, + }; + this.updateSky(); + } - private updateParameters(parameters: any) { - for (let propertyName in parameters) { - if (this.parameters.hasOwnProperty(propertyName)) { - this.parameters[propertyName] = parameters[propertyName]; - } - } + private updateParameters(parameters: any) { + for (const propertyName in parameters) { + if (this.parameters.hasOwnProperty(propertyName)) { + this.parameters[propertyName] = parameters[propertyName]; + } } + } - public updateSky() { - this.sky.scale.setScalar(450000); - this.sky.frustumCulled = false; - - this.sky.material.uniforms.turbidity.value = this.parameters.turbidity; - this.sky.material.uniforms.rayleigh.value = this.parameters.rayleigh; - this.sky.material.uniforms.mieCoefficient.value = this.parameters.mieCoefficient; - this.sky.material.uniforms.mieDirectionalG.value = this.parameters.mieDirectionalG; - let sunPosition = viewSpacePositionFromUV( - this.parameters.distance, - this.parameters.azimuth, - this.parameters.inclination, - ); - this.sky.material.uniforms.sunPosition.value.copy(sunPosition); - this.sky.visible = this.parameters.visible; - /* + public updateSky() { + this.sky.scale.setScalar(450000); + this.sky.frustumCulled = false; + + this.sky.material.uniforms.turbidity.value = this.parameters.turbidity; + this.sky.material.uniforms.rayleigh.value = this.parameters.rayleigh; + this.sky.material.uniforms.mieCoefficient.value = + this.parameters.mieCoefficient; + this.sky.material.uniforms.mieDirectionalG.value = + this.parameters.mieDirectionalG; + const sunPosition = viewSpacePositionFromUV( + this.parameters.distance, + this.parameters.azimuth, + this.parameters.inclination + ); + this.sky.material.uniforms.sunPosition.value.copy(sunPosition); + this.sky.visible = this.parameters.visible; + /* const sunSphere = new Mesh( new SphereGeometry(20000, 16, 8), new MeshBasicMaterial({ color: 0xffffff }) @@ -72,39 +72,44 @@ export class SkyEnvironment { sunSphere.position.set(sunPosition.x, -sunPosition.z, sunPosition.y); //sunSphere.visible = true; */ - } + } - public addToScene(scene: Object3D) { - scene.add(this.sky); - } + public addToScene(scene: Object3D) { + scene.add(this.sky); + } - public changeVisibility(visible: boolean) { - if (this.parameters.visible !== visible) { - this.updateParameters({ visible }); - this.updateSky(); - } + public changeVisibility(visible: boolean) { + if (this.parameters.visible !== visible) { + this.updateParameters({ visible }); + this.updateSky(); } + } } export class SkyEnvironmentGUI { - private skyEnvironment: SkyEnvironment; - private showSkyController?: GUIController; + private skyEnvironment: SkyEnvironment; + private showSkyController?: GUIController; - constructor(skyEnvironment: SkyEnvironment) { - this.skyEnvironment = skyEnvironment; - } + constructor(skyEnvironment: SkyEnvironment) { + this.skyEnvironment = skyEnvironment; + } - public hideSky(): void { - this.showSkyController?.setValue(false); - this.showSkyController?.updateDisplay(); - } + public hideSky(): void { + this.showSkyController?.setValue(false); + this.showSkyController?.updateDisplay(); + } - public addGUI(gui: GUI, updateCallback?: (skyEnvironment: SkyEnvironment) => void): void { - this.showSkyController = gui.add(this.skyEnvironment.parameters, 'visible').onChange(() => { - this.skyEnvironment.updateSky(); - if (updateCallback) { - updateCallback(this.skyEnvironment); - } - }); - } + public addGUI( + gui: GUI, + updateCallback?: (skyEnvironment: SkyEnvironment) => void + ): void { + this.showSkyController = gui + .add(this.skyEnvironment.parameters, 'visible') + .onChange(() => { + this.skyEnvironment.updateSky(); + if (updateCallback) { + updateCallback(this.skyEnvironment); + } + }); + } } diff --git a/src/client/threeClient.ts b/src/client/threeClient.ts index cfc5236..6a485bb 100644 --- a/src/client/threeClient.ts +++ b/src/client/threeClient.ts @@ -1,128 +1,134 @@ -import { setupDragDrop } from './util/drag_target' -import { glbMap } from './glbMap' +import { setupDragDrop } from './util/drag_target'; +import { glbMap } from './glbMap'; import { SceneManager } from './scene/sceneManager'; -import { QualityLevel} from './renderer/scene-renderer' -import { SceneRendererGUI } from './renderer/scene-renderer-gui' -import { MaterialGUI } from './scene/material-gui' -import { LightSourcesGUI } from './scene/lightSources' -import { SkyEnvironment, SkyEnvironmentGUI } from './scene/skyEnvironment'; -import { BackgroundEnvironment, BackgroundEnvironmentGUI } from './renderer/background-environment'; -import { GroundMaterialType } from './scene/materials' -import { Group, Vector2, WebGLRenderer } from 'three' +import { QualityLevel } from './renderer/scene-renderer'; +import { SceneRendererGUI } from './renderer/scene-renderer-gui'; +import { MaterialGUI } from './scene/material-gui'; +import { LightSourcesGUI } from './scene/lightSources'; +import type { SkyEnvironment } from './scene/skyEnvironment'; +import { SkyEnvironmentGUI } from './scene/skyEnvironment'; +import type { BackgroundEnvironment } from './renderer/background-environment'; +import { BackgroundEnvironmentGUI } from './renderer/background-environment'; +import { GroundMaterialType } from './scene/materials'; +import type { Group } from 'three'; +import { Vector2, WebGLRenderer } from 'three'; import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js'; -// @ts-ignore -import Stats from 'three/examples/jsm/libs/stats.module' -import { GUI } from 'dat.gui' +import Stats from 'three/examples/jsm/libs/stats.module'; +import { GUI } from 'dat.gui'; const getDeviceType = () => { - const ua = navigator.userAgent; - if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) { - return "tablet"; - } - else if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(ua)) { - return "mobile"; - } - return "desktop"; -} -const deviceType = getDeviceType() -console.log(deviceType) -const isMobile = deviceType === 'mobile' + const ua = navigator.userAgent; + if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) { + return 'tablet'; + } else if ( + /Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test( + ua + ) + ) { + return 'mobile'; + } + return 'desktop'; +}; +const deviceType = getDeviceType(); +console.log(deviceType); +const isMobile = deviceType === 'mobile'; -const queryString = window.location.search; -const urlParams = new URLSearchParams(queryString); -const parameterId = urlParams.get('id') +//const queryString = window.location.search; +//const urlParams = new URLSearchParams(queryString); +//const parameterId = urlParams.get('id'); -const sceneCache: any = {} +const sceneCache: any = {}; const setStatus = (message: string, color: string = '#000000') => { - console.log(`Status information: ${message}`); - const statusLine = document.getElementById("status-line"); - if (!statusLine) { - return - } - statusLine.innerText = message - statusLine.style.setProperty('color', color) -} + console.log(`Status information: ${message}`); + const statusLine = document.getElementById('status-line'); + if (!statusLine) { + return; + } + statusLine.innerText = message; + statusLine.style.setProperty('color', color); +}; const finishScene = (sceneName: string) => { - let materialData = renderScene.collectMaterials(); - materialGUI.updateMaterialUI(gui, materialData); - setStatus(`${sceneName}`); - generalProperties.sceneName = sceneName.replace(/:/g, '_'); -} -const loadConfiguratorMesh = async (configurationId: string) => { -const statusLine = document.getElementById("status-line"); - let loadedScene = sceneCache[configurationId]; - if (!loadedScene) { - return; - } - setStatus(`render ${configurationId}`, '#ff0000') - renderScene.update(undefined, loadedScene.scene, loadedScene.glb); - finishScene(configurationId); -} + const materialData = renderScene.collectMaterials(); + materialGUI.updateMaterialUI(gui, materialData); + setStatus(`${sceneName}`); + generalProperties.sceneName = sceneName.replace(/:/g, '_'); +}; const loadGlbMesh = async (glbName: string, glbUrl: string) => { - let loadedScene = sceneCache[glbUrl]; - if (!loadedScene) { - await renderScene.loadResource(glbName + '.glb', glbUrl, - (_:string) => {}, - (modelName: string, sceneGroup: Group | null) => { - if (sceneGroup) { - sceneCache[glbUrl] = { scene: sceneGroup, glb: true }; - finishScene(modelName); - } else { - setStatus(`load ${modelName}`, '#ff0000'); - } - } - ); - loadedScene = sceneCache[glbUrl]; - } - setStatus(`render ${glbUrl}`, '#ff0000') - renderScene.update(undefined, loadedScene.scene, loadedScene.glb); - finishScene(glbUrl); -} + let loadedScene = sceneCache[glbUrl]; + if (!loadedScene) { + await renderScene.loadResource( + glbName + '.glb', + glbUrl, + (_: string) => {}, + (modelName: string, sceneGroup: Group | null) => { + if (sceneGroup) { + sceneCache[glbUrl] = { scene: sceneGroup, glb: true }; + finishScene(modelName); + } else { + setStatus(`load ${modelName}`, '#ff0000'); + } + } + ); + loadedScene = sceneCache[glbUrl]; + } + setStatus(`render ${glbUrl}`, '#ff0000'); + renderScene.update(undefined, loadedScene.scene, loadedScene.glb); + finishScene(glbUrl); +}; const loadResource = (resourceName: string, resource: string) => { - const loadedScene = sceneCache[resourceName]; - if (loadedScene) { - setStatus(`render ${resourceName}`, '#ff0000') - renderScene.update(undefined, loadedScene.scene, loadedScene.glb); - finishScene(resourceName); - } else { - renderScene.loadResource(resourceName, resource, - (_:string) => {}, - (modelName: string, sceneGroup: Group | null) => { - if (sceneGroup) { - sceneCache[resourceName] = { scene: sceneGroup, glb: true }; - finishScene(modelName); - addNewGlbToMenu(resourceName); - } else { - setStatus(`load ${modelName}`, '#ff0000'); - } - } - ); - } -} + const loadedScene = sceneCache[resourceName]; + if (loadedScene) { + setStatus(`render ${resourceName}`, '#ff0000'); + renderScene.update(undefined, loadedScene.scene, loadedScene.glb); + finishScene(resourceName); + } else { + renderScene.loadResource( + resourceName, + resource, + (_: string) => {}, + (modelName: string, sceneGroup: Group | null) => { + if (sceneGroup) { + sceneCache[resourceName] = { scene: sceneGroup, glb: true }; + finishScene(modelName); + addNewGlbToMenu(resourceName); + } else { + setStatus(`load ${modelName}`, '#ff0000'); + } + } + ); + } +}; const setGroundMaterial = () => { - let groundMaterial: GroundMaterialType = GroundMaterialType.Transparent - switch(generalProperties.groundMaterial.toLocaleLowerCase()) { - default: groundMaterial = GroundMaterialType.Transparent; break - case 'parquet': groundMaterial = GroundMaterialType.Parquet; break - case 'pavement': groundMaterial = GroundMaterialType.Pavement; break - } - renderScene.setGroundMaterial(groundMaterial) -} + let groundMaterial: GroundMaterialType = GroundMaterialType.Transparent; + switch (generalProperties.groundMaterial.toLocaleLowerCase()) { + default: + groundMaterial = GroundMaterialType.Transparent; + break; + case 'parquet': + groundMaterial = GroundMaterialType.Parquet; + break; + case 'pavement': + groundMaterial = GroundMaterialType.Pavement; + break; + } + renderScene.setGroundMaterial(groundMaterial); +}; -let fixedResolution: any = undefined; +const fixedResolution: any = undefined; +const threeCanvas = document.getElementById('three_canvas'); const renderer = new WebGLRenderer({ - // @ts-ignore - canvas: three_canvas, - antialias: true, - alpha: true, - preserveDrawingBuffer: true, + // @ts-ignore + canvas: threeCanvas, + antialias: true, + alpha: true, + preserveDrawingBuffer: true, }); renderer.setPixelRatio(window.devicePixelRatio); //renderer.physicallyCorrectLights = true -renderer.setSize(window.innerWidth, window.innerHeight) -document.body.appendChild(renderer.domElement) +renderer.setSize(window.innerWidth, window.innerHeight); +document.body.appendChild(renderer.domElement); const labelRenderer = new CSS2DRenderer(); labelRenderer.setSize(window.innerWidth, window.innerHeight); labelRenderer.domElement.style.position = 'absolute'; @@ -134,126 +140,160 @@ document.body.appendChild(labelRenderer.domElement); const stats = new Stats(); document.body.appendChild(stats.dom); -let generalProperties = { - rotate: 0, - randomOrientation: false, - dimensions: false, - materialNoise: false, - glb: '', - autoLoad: false, - autoLoadSaveScene: false, - groundMaterial: 'onlyshadow', - bloom: false, - ssr: false, - sceneName: 'default', -} +const generalProperties = { + rotate: 0, + randomOrientation: false, + dimensions: false, + materialNoise: false, + glb: '', + autoLoad: false, + autoLoadSaveScene: false, + groundMaterial: 'onlyshadow', + bloom: false, + ssr: false, + sceneName: 'default', +}; const renderScene = new SceneManager(renderer, labelRenderer); -renderScene.sceneRenderer.setQualityLevel(isMobile ? QualityLevel.LOW : QualityLevel.HIGHEST); +renderScene.sceneRenderer.setQualityLevel( + isMobile ? QualityLevel.LOW : QualityLevel.HIGHEST +); renderScene.createControls(); renderScene.setEnvironment(); renderScene.updateSceneDependencies(); -setGroundMaterial() +setGroundMaterial(); -const gui = new GUI() -const glbMenuItems: any[] = Object.assign({}, ...glbMap.map((item: any) => ({[item.name]: item.url}))); -const glbMenu = gui.add(generalProperties, 'glb', glbMenuItems).onChange((value) => { +const gui = new GUI(); +const glbMenuItems: any[] = Object.assign( + {}, + ...glbMap.map((item: any) => ({ [item.name]: item.url })) +); +const glbMenu = gui + .add(generalProperties, 'glb', glbMenuItems) + .onChange((value) => { if (value !== '') { - const index = glbMap.findIndex((item: any) => item.url === value); - const glbName = index >= 0 ? glbMap[index].name : value; - loadGlbMesh(glbName, value); + const index = glbMap.findIndex((item: any) => item.url === value); + const glbName = index >= 0 ? glbMap[index].name : value; + loadGlbMesh(glbName, value); } -}); + }); const loadGlbFromMap = (name: string) => { - const index = glbMap.findIndex((item: any) => item.name === name); - if (index >= 0) { - const glb = glbMap[index]; - loadGlbMesh(glb.name, glb.url); - } + const index = glbMap.findIndex((item: any) => item.name === name); + if (index >= 0) { + const glb = glbMap[index]; + loadGlbMesh(glb.name, glb.url); + } }; const addNewGlbToMenu = (resourceName: string) => { - glbMenuItems.push(resourceName); - let innerHTMLStr = ""; - glbMenuItems.forEach((value) => { - innerHTMLStr += ""; - }); - glbMenu.domElement.children[0].innerHTML = innerHTMLStr; - glbMenu.setValue(resourceName); - glbMenu.updateDisplay(); -} -gui.add(generalProperties, 'randomOrientation').onChange(() => renderScene.update(generalProperties)); + glbMenuItems.push(resourceName); + let innerHTMLStr = ''; + glbMenuItems.forEach((value) => { + innerHTMLStr += + ''; + }); + glbMenu.domElement.children[0].innerHTML = innerHTMLStr; + glbMenu.setValue(resourceName); + glbMenu.updateDisplay(); +}; +gui + .add(generalProperties, 'randomOrientation') + .onChange(() => renderScene.update(generalProperties)); //gui.add(generalProperties, 'rotate', 0, 0.25).onChange(() => renderScene.update(generalProperties)) -gui.add(generalProperties, 'dimensions').onChange(() => renderScene.update(generalProperties)); -gui.add(generalProperties, 'groundMaterial', { +gui + .add(generalProperties, 'dimensions') + .onChange(() => renderScene.update(generalProperties)); +gui + .add(generalProperties, 'groundMaterial', { 'only shadow': 'onlyshadow', - 'parquet': 'parquet', - 'pavement': 'pavement' -}).onChange(() => setGroundMaterial()) + 'parquet': 'parquet', + 'pavement': 'pavement', + }) + .onChange(() => setGroundMaterial()); const environmentFolder = gui.addFolder('environment'); -const showEnvironmentController = environmentFolder.add(renderScene, 'showEnvironment').onChange((value) => { +const showEnvironmentController = environmentFolder + .add(renderScene, 'showEnvironment') + .onChange((value) => { if (value) { - skyEnvironmentGUI.hideSky(); - backgroundEnvironmentGUI.hideBackground(); + skyEnvironmentGUI.hideSky(); + backgroundEnvironmentGUI.hideBackground(); } -}); -environmentFolder.add(renderScene, 'environmentRotation', 0, Math.PI*2, 0.01).onChange((value) => { + }); +environmentFolder + .add(renderScene, 'environmentRotation', 0, Math.PI * 2, 0.01) + .onChange((value) => { if (renderScene.scene.userData?.environmentDefinition) { - renderScene.scene.userData.environmentDefinition.rotation = value; + renderScene.scene.userData.environmentDefinition.rotation = value; } -}); -environmentFolder.add(renderScene, 'environmentIntensity', 0, 5, 0.01).onChange((value) => { + }); +environmentFolder + .add(renderScene, 'environmentIntensity', 0, 5, 0.01) + .onChange((value) => { if (renderScene.scene.userData?.environmentDefinition) { - renderScene.scene.userData.environmentDefinition.intensity = value; + renderScene.scene.userData.environmentDefinition.intensity = value; } -}); + }); const skyEnvironmentFolder = environmentFolder.addFolder('sky'); const skyEnvironmentGUI = new SkyEnvironmentGUI(renderScene.skyEnvironment); -skyEnvironmentGUI.addGUI(skyEnvironmentFolder, (skyEnvironment: SkyEnvironment) => { +skyEnvironmentGUI.addGUI( + skyEnvironmentFolder, + (skyEnvironment: SkyEnvironment) => { if (skyEnvironment.parameters.visible) { - showEnvironmentController.setValue(false); - showEnvironmentController.updateDisplay(); - backgroundEnvironmentGUI.hideBackground(); + showEnvironmentController.setValue(false); + showEnvironmentController.updateDisplay(); + backgroundEnvironmentGUI.hideBackground(); } -}); + } +); const backgroundEnvironmentFolder = environmentFolder.addFolder('background'); -const backgroundEnvironmentGUI = new BackgroundEnvironmentGUI(renderScene.backgroundEnvironment); -backgroundEnvironmentGUI.addGUI(backgroundEnvironmentFolder, (backgroundEnvironment: BackgroundEnvironment) => { +const backgroundEnvironmentGUI = new BackgroundEnvironmentGUI( + renderScene.backgroundEnvironment +); +backgroundEnvironmentGUI.addGUI( + backgroundEnvironmentFolder, + (backgroundEnvironment: BackgroundEnvironment) => { if (backgroundEnvironment.parameters.isSet) { - showEnvironmentController.setValue(false); - showEnvironmentController.updateDisplay(); - skyEnvironmentGUI.hideSky(); + showEnvironmentController.setValue(false); + showEnvironmentController.updateDisplay(); + skyEnvironmentGUI.hideSky(); } -}); + } +); renderScene.environmentLoader.addGUI(environmentFolder); const sceneRendererGUI = new SceneRendererGUI(renderScene.sceneRenderer); sceneRendererGUI.addGUI(gui, () => {}); const materialGUI = new MaterialGUI(); -const lightFolder = gui.addFolder('Light') +const lightFolder = gui.addFolder('Light'); const lightSourceGUI = new LightSourcesGUI(renderScene.getLightSources()); -lightSourceGUI.addGUI(lightFolder, - () => (on: boolean) => renderScene.changeLightControls(on), - () => renderScene.updateSceneDependencies()); +lightSourceGUI.addGUI( + lightFolder, + () => (on: boolean) => renderScene.changeLightControls(on), + () => renderScene.updateSceneDependencies() +); const onWindowResize = () => { - const width = fixedResolution?.width ?? window.innerWidth - const height = fixedResolution?.height ?? window.innerHeight - renderScene.resize(width, height) -} -window.addEventListener('resize', onWindowResize, false) -const mousePosition = new Vector2() + const width = fixedResolution?.width ?? window.innerWidth; + const height = fixedResolution?.height ?? window.innerHeight; + renderScene.resize(width, height); +}; +window.addEventListener('resize', onWindowResize, false); +const mousePosition = new Vector2(); const onPointerMove = (event: any) => { - if (event.isPrimary === false ) { - return - } - mousePosition.x = (event.clientX / window.innerWidth) * 2 - 1; - mousePosition.y = - (event.clientY / window.innerHeight) * 2 + 1; -} + if (event.isPrimary === false) { + return; + } + mousePosition.x = (event.clientX / window.innerWidth) * 2 - 1; + mousePosition.y = -(event.clientY / window.innerHeight) * 2 + 1; +}; renderer.domElement.addEventListener('pointermove', onPointerMove); -setupDragDrop('holder', 'hover', (file: File, event: ProgressEvent) => { +setupDragDrop( + 'holder', + 'hover', + (file: File, event: ProgressEvent) => { // @ts-ignore loadResource(file.name, event.target.result); -}); + } +); const saveDocumentLink = document.createElement('a'); const saveSceneToFile = (fileName: string) => { @@ -263,62 +303,64 @@ const saveSceneToFile = (fileName: string) => { saveDocumentLink.click(); }; const renderAndSaveToFile = (renderMode: string, fileName: string) => { - const renderModeBackup = renderScene.sceneRenderer.debugOutput; - renderScene.sceneRenderer.debugOutput = renderMode; - renderScene.prepareRender(new Vector2()); - renderScene.render(false); - saveSceneToFile(fileName); - renderScene.sceneRenderer.debugOutput = renderModeBackup; + const renderModeBackup = renderScene.sceneRenderer.debugOutput; + renderScene.sceneRenderer.debugOutput = renderMode; + renderScene.prepareRender(new Vector2()); + renderScene.render(false); + saveSceneToFile(fileName); + renderScene.sceneRenderer.debugOutput = renderModeBackup; }; const saveScene = () => { - try { - saveSceneToFile(generalProperties.sceneName + '.png'); - } - catch(e) { - console.log(e); - } -} + try { + saveSceneToFile(generalProperties.sceneName + '.png'); + } catch (e) { + console.log(e); + } +}; const saveButton = document.getElementById('save-button'); if (saveButton) { - saveButton.onclick = () => saveScene(); -}; -const saveGBuffer = () => { - try { - renderAndSaveToFile('color', generalProperties.sceneName + '_color.png'); - renderAndSaveToFile('g-normal', generalProperties.sceneName + '_normal.png'); - renderAndSaveToFile('g-depth', generalProperties.sceneName + '_depth.png'); - } - catch(e) { - console.log(e); - } + saveButton.onclick = () => saveScene(); } +const saveGBuffer = () => { + try { + renderAndSaveToFile('color', generalProperties.sceneName + '_color.png'); + renderAndSaveToFile( + 'g-normal', + generalProperties.sceneName + '_normal.png' + ); + renderAndSaveToFile('g-depth', generalProperties.sceneName + '_depth.png'); + } catch (e) { + console.log(e); + } +}; const saveGBufferButton = document.getElementById('save-g-buffer-button'); if (saveGBufferButton) { - saveGBufferButton.onclick = () => saveGBuffer(); -}; + saveGBufferButton.onclick = () => saveGBuffer(); +} -let start: number, previousTimeStamp: number; +let start: number; +let previousTimeStamp: number; const animate = (timestamp: number) => { - if (start === undefined) { - start = timestamp; - } - if (previousTimeStamp === undefined) { - previousTimeStamp = timestamp; - } - const elapsedMilliseconds = timestamp - previousTimeStamp; - previousTimeStamp = timestamp - renderScene.animate(elapsedMilliseconds) - //stats.begin(); - render() - //stats.end(); - requestAnimationFrame(animate) -} + if (start === undefined) { + start = timestamp; + } + if (previousTimeStamp === undefined) { + previousTimeStamp = timestamp; + } + const elapsedMilliseconds = timestamp - previousTimeStamp; + previousTimeStamp = timestamp; + renderScene.animate(elapsedMilliseconds); + //stats.begin(); + render(); + //stats.end(); + requestAnimationFrame(animate); +}; const render = () => { - renderScene.prepareRender(mousePosition) - renderScene.render() - stats.update() -} + renderScene.prepareRender(mousePosition); + renderScene.render(); + stats.update(); +}; loadGlbFromMap('BrainStem'); -requestAnimationFrame(animate) +requestAnimationFrame(animate); diff --git a/src/client/util/drag_target.ts b/src/client/util/drag_target.ts index a9683d5..9a0cc99 100644 --- a/src/client/util/drag_target.ts +++ b/src/client/util/drag_target.ts @@ -1,26 +1,30 @@ -export const setupDragDrop = (elementId: string, className: string, load: (file: File, event: ProgressEvent) => void) => { - const holder = document.getElementById(elementId); - if (!holder) { - return; - } - holder.ondragover = function(){ - // @ts-ignore - this.className = className; - return false; - }; - holder.ondragend = function(){ - // @ts-ignore - this.className = ''; - return false; - }; - holder.ondrop = function(e){ - // @ts-ignore - this.className = ''; - e.preventDefault(); - // @ts-ignore - const file = e.dataTransfer.files[0]; - const reader = new FileReader(); - reader.onload = (event) => load(file, event); - reader.readAsDataURL(file); - } -}; \ No newline at end of file +export const setupDragDrop = ( + elementId: string, + className: string, + load: (file: File, event: ProgressEvent) => void +) => { + const holder = document.getElementById(elementId); + if (!holder) { + return; + } + holder.ondragover = function () { + // @ts-ignore + this.className = className; + return false; + }; + holder.ondragend = function () { + // @ts-ignore + this.className = ''; + return false; + }; + holder.ondrop = function (e) { + // @ts-ignore + this.className = ''; + e.preventDefault(); + // @ts-ignore + const file = e.dataTransfer.files[0]; + const reader = new FileReader(); + reader.onload = (event) => load(file, event); + reader.readAsDataURL(file); + }; +}; diff --git a/src/server/three_server.ts b/src/server/three_server.ts index bd97e05..bdfdaf3 100644 --- a/src/server/three_server.ts +++ b/src/server/three_server.ts @@ -1,26 +1,26 @@ -import express from 'express' -import path from 'path' -import http from 'http' +import express from 'express'; +import path from 'path'; +import http from 'http'; -const port: number = 3333 -const hostname:string = '127.0.0.1' +const port: number = 3333; +const hostname: string = '127.0.0.1'; class App { - private server: http.Server - private port: number + private server: http.Server; + private port: number; - constructor(port: number) { - this.port = port - const app = express() - app.use(express.static(path.join(__dirname, '../client'))) - this.server = new http.Server(app) - } + constructor(portNumber: number) { + this.port = portNumber; + const app = express(); + app.use(express.static(path.join(__dirname, '../client'))); + this.server = new http.Server(app); + } - public Start() { - this.server.listen(this.port, () => { - console.log(`Server running at http://${hostname}:${port}/`) - }) - } + public Start() { + this.server.listen(this.port, () => { + console.log(`Server running at http://${hostname}:${port}/`); + }); + } } -new App(port).Start() \ No newline at end of file +new App(port).Start(); diff --git a/src/shaders/SSRShader.js b/src/shaders/SSRShader.js index fd116de..6c49297 100644 --- a/src/shaders/SSRShader.js +++ b/src/shaders/SSRShader.js @@ -26,22 +26,22 @@ const SSRShader = { uniforms: { - 'tDiffuse': { value: null }, - 'tNormal': { value: null }, - 'tDepth': { value: null }, - 'tIllumination': { value: null }, - 'cameraNear': { value: null }, - 'cameraFar': { value: null }, - 'resolution': { value: new Vector2() }, - 'cameraProjectionMatrix': { value: new Matrix4() }, - 'cameraInverseProjectionMatrix': { value: new Matrix4() }, - 'cameraMatrixWorld': { value: new Matrix4() }, - 'sceneBoxMin': { value: new Vector3(-1, -1, -1) }, - 'sceneBoxMax': { value: new Vector3(1, 1, 1) }, - 'opacity': { value: .5 }, - 'maxDistance': { value: 180 }, - 'cameraRange': { value: 0 }, - 'thickness': { value: .018 } + tDiffuse: { value: null }, + tNormal: { value: null }, + tDepth: { value: null }, + tIllumination: { value: null }, + cameraNear: { value: null }, + cameraFar: { value: null }, + resolution: { value: new Vector2() }, + cameraProjectionMatrix: { value: new Matrix4() }, + cameraInverseProjectionMatrix: { value: new Matrix4() }, + cameraMatrixWorld: { value: new Matrix4() }, + sceneBoxMin: { value: new Vector3(-1, -1, -1) }, + sceneBoxMax: { value: new Vector3(1, 1, 1) }, + opacity: { value: .5 }, + maxDistance: { value: 180 }, + cameraRange: { value: 0 }, + thickness: { value: .018 } }, @@ -282,14 +282,14 @@ const SSRDepthShader = { name: 'SSRDepthShader', defines: { - 'PERSPECTIVE_CAMERA': 1 + PERSPECTIVE_CAMERA: 1 }, uniforms: { - 'tDepth': { value: null }, - 'cameraNear': { value: null }, - 'cameraFar': { value: null }, + tDepth: { value: null }, + cameraNear: { value: null }, + cameraFar: { value: null }, }, @@ -352,9 +352,9 @@ const SSRBlurShader = { uniforms: { - 'tDiffuse': { value: null }, - 'resolution': { value: new Vector2() }, - 'opacity': { value: .5 }, + tDiffuse: { value: null }, + resolution: { value: new Vector2() }, + opacity: { value: .5 }, },