shaders 2.0.0-alpha.4 → 2.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/components/FilmGrain.d.ts +22 -0
- package/dist/react/components/FilmGrain.d.ts.map +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/vue/components/FilmGrain.vue.d.ts +51 -0
- package/dist/vue/components/FilmGrain.vue.d.ts.map +1 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { BlendMode } from 'shaders-core';
|
|
3
|
+
import { ComponentProps } from 'shaders-core/filmGrain';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Define component props including blend mode, opacity, and masking
|
|
7
|
+
*/
|
|
8
|
+
interface OmbreComponentProps extends Partial<ComponentProps> {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
blendMode?: BlendMode;
|
|
11
|
+
opacity?: number;
|
|
12
|
+
id?: string;
|
|
13
|
+
maskSource?: string;
|
|
14
|
+
maskType?: string;
|
|
15
|
+
ref?: React.Ref<any>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The main React wrapper component for Shader shader nodes
|
|
19
|
+
*/
|
|
20
|
+
export declare const OmbreComponent: React.FC<OmbreComponentProps>;
|
|
21
|
+
export default OmbreComponent;
|
|
22
|
+
//# sourceMappingURL=FilmGrain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilmGrain.d.ts","sourceRoot":"","sources":["../../src/components/FilmGrain.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AACtE,OAAO,EAGH,KAAK,SAAS,EAIjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIlF;;GAEG;AACH,UAAU,mBAAoB,SAAQ,OAAO,CAAC,cAAc,CAAC;IACzD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACxB;AAwCD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA8IxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/dist/react/index.cjs
CHANGED
|
@@ -147,7 +147,7 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
|
|
|
147
147
|
* @license
|
|
148
148
|
* Copyright 2010-2025 Three.js Authors
|
|
149
149
|
* SPDX-License-Identifier: MIT
|
|
150
|
-
*/y.BRDF_GGX;y.BRDF_Lambert;y.BasicShadowFilter;y.Break;y.Continue;y.DFGApprox;y.D_GGX;y.Discard;y.EPSILON;y.F_Schlick;y.Fn;y.INFINITY;y.If;y.Switch;y.Loop;y.NodeShaderStage;y.NodeType;y.NodeUpdateType;y.NodeAccess;y.PCFShadowFilter;y.PCFSoftShadowFilter;y.PI;y.PI2;y.Return;y.Schlick_to_F0;y.ScriptableNodeResources;y.ShaderNode;y.TBNViewMatrix;y.VSMShadowFilter;y.V_GGX_SmithCorrelated;y.abs;y.acesFilmicToneMapping;y.acos;y.add;y.addNodeElement;y.agxToneMapping;y.all;y.alphaT;y.and;y.anisotropy;y.anisotropyB;y.anisotropyT;y.any;y.append;y.array;y.arrayBuffer;y.asin;y.assign;y.atan;y.atan2;y.atomicAdd;y.atomicAnd;y.atomicFunc;y.atomicMax;y.atomicMin;y.atomicOr;y.atomicStore;y.atomicSub;y.atomicXor;y.atomicLoad;y.attenuationColor;y.attenuationDistance;y.attribute;y.attributeArray;y.backgroundBlurriness;y.backgroundIntensity;y.backgroundRotation;y.batch;y.billboarding;y.bitAnd;y.bitNot;y.bitOr;y.bitXor;y.bitangentGeometry;y.bitangentLocal;y.bitangentView;y.bitangentWorld;y.bitcast;y.blendBurn;y.blendColor;y.blendDodge;y.blendOverlay;y.blendScreen;y.blur;y.bool;y.buffer;y.bufferAttribute;y.bumpMap;y.burn;y.bvec2;y.bvec3;y.bvec4;y.bypass;y.cache;y.call;y.cameraFar;y.cameraIndex;y.cameraNear;y.cameraNormalMatrix;y.cameraPosition;y.cameraProjectionMatrix;y.cameraProjectionMatrixInverse;y.cameraViewMatrix;y.cameraWorldMatrix;y.cbrt;y.cdl;y.ceil;y.checker;y.cineonToneMapping;y.clamp;y.clearcoat;y.clearcoatRoughness;y.code;y.color;y.colorSpaceToWorking;y.colorToDirection;y.compute;y.computeSkinning;y.cond;y.Const;y.context;y.convert;y.convertColorSpace;y.convertToTexture;y.cos;y.cross;y.cubeTexture;y.dFdx;y.dFdy;y.dashSize;y.debug;y.decrement;y.decrementBefore;y.defaultBuildStages;y.defaultShaderStages;y.defined;y.degrees;y.deltaTime;y.densityFog;y.densityFogFactor;y.depth;y.depthPass;y.difference;y.diffuseColor;y.directPointLight;y.directionToColor;y.dispersion;y.distance;y.div;y.dodge;y.dot;y.drawIndex;y.dynamicBufferAttribute;y.element;y.emissive;y.equal;y.equals;y.equirectUV;y.exp;y.exp2;y.expression;y.faceDirection;y.faceForward;y.faceforward;y.float;y.floor;y.fog;y.fract;y.frameGroup;y.frameId;y.frontFacing;y.fwidth;y.gain;y.gapSize;y.getConstNodeType;y.getCurrentStack;y.getDirection;y.getDistanceAttenuation;y.getGeometryRoughness;y.getNormalFromDepth;y.getParallaxCorrectNormal;y.getRoughness;y.getScreenPosition;y.getShIrradianceAt;y.getTextureIndex;y.getViewPosition;y.getShadowMaterial;y.getShadowRenderObjectFunction;y.glsl;y.glslFn;y.grayscale;y.greaterThan;y.greaterThanEqual;y.hash;y.highpModelNormalViewMatrix;y.highpModelViewMatrix;y.hue;y.increment;y.incrementBefore;y.instance;y.instanceIndex;y.instancedArray;y.instancedBufferAttribute;y.instancedDynamicBufferAttribute;y.instancedMesh;y.int;y.inverseSqrt;y.inversesqrt;y.invocationLocalIndex;y.invocationSubgroupIndex;y.ior;y.iridescence;y.iridescenceIOR;y.iridescenceThickness;y.ivec2;y.ivec3;y.ivec4;y.js;y.label;y.length;y.lengthSq;y.lessThan;y.lessThanEqual;y.lightPosition;y.lightShadowMatrix;y.lightTargetDirection;y.lightTargetPosition;y.lightViewPosition;y.lightingContext;y.lights;y.linearDepth;y.linearToneMapping;y.localId;y.globalId;y.log;y.log2;y.logarithmicDepthToViewZ;y.loop;y.luminance;y.mediumpModelViewMatrix;y.mat2;y.mat3;y.mat4;y.matcapUV;y.materialAO;y.materialAlphaTest;y.materialAnisotropy;y.materialAnisotropyVector;y.materialAttenuationColor;y.materialAttenuationDistance;y.materialClearcoat;y.materialClearcoatNormal;y.materialClearcoatRoughness;y.materialColor;y.materialDispersion;y.materialEmissive;y.materialIOR;y.materialIridescence;y.materialIridescenceIOR;y.materialIridescenceThickness;y.materialLightMap;y.materialLineDashOffset;y.materialLineDashSize;y.materialLineGapSize;y.materialLineScale;y.materialLineWidth;y.materialMetalness;y.materialNormal;y.materialOpacity;y.materialPointSize;y.materialReference;y.materialReflectivity;y.materialRefractionRatio;y.materialRotation;y.materialRoughness;y.materialSheen;y.materialSheenRoughness;y.materialShininess;y.materialSpecular;y.materialSpecularColor;y.materialSpecularIntensity;y.materialSpecularStrength;y.materialThickness;y.materialTransmission;y.max;y.maxMipLevel;y.metalness;y.min;y.mix;y.mixElement;y.mod;y.modInt;y.modelDirection;y.modelNormalMatrix;y.modelPosition;y.modelRadius;y.modelScale;y.modelViewMatrix;y.modelViewPosition;y.modelViewProjection;y.modelWorldMatrix;y.modelWorldMatrixInverse;y.morphReference;y.mrt;y.mul;y.mx_aastep;y.mx_cell_noise_float;y.mx_contrast;y.mx_fractal_noise_float;y.mx_fractal_noise_vec2;y.mx_fractal_noise_vec3;y.mx_fractal_noise_vec4;y.mx_hsvtorgb;y.mx_noise_float;y.mx_noise_vec3;y.mx_noise_vec4;y.mx_ramplr;y.mx_ramptb;y.mx_rgbtohsv;y.mx_safepower;y.mx_splitlr;y.mx_splittb;y.mx_srgb_texture_to_lin_rec709;y.mx_transform_uv;y.mx_worley_noise_float;y.mx_worley_noise_vec2;y.mx_worley_noise_vec3;y.namespace;y.negate;y.neutralToneMapping;y.nodeArray;y.nodeImmutable;y.nodeObject;y.nodeObjects;y.nodeProxy;y.normalFlat;y.normalGeometry;y.normalLocal;y.normalMap;y.normalView;y.normalWorld;y.normalize;y.not;y.notEqual;y.numWorkgroups;y.objectDirection;y.objectGroup;y.objectPosition;y.objectRadius;y.objectScale;y.objectViewPosition;y.objectWorldMatrix;y.oneMinus;y.or;y.orthographicDepthToViewZ;y.oscSawtooth;y.oscSine;y.oscSquare;y.oscTriangle;y.output;y.outputStruct;y.overlay;y.overloadingFn;y.parabola;y.parallaxDirection;y.parallaxUV;y.parameter;y.pass;y.passTexture;y.pcurve;y.perspectiveDepthToViewZ;y.pmremTexture;y.pointUV;y.pointWidth;y.positionGeometry;y.positionLocal;y.positionPrevious;y.positionView;y.positionViewDirection;y.positionWorld;y.positionWorldDirection;y.posterize;y.pow;y.pow2;y.pow3;y.pow4;y.premult;y.property;y.radians;y.rand;y.range;y.rangeFog;y.rangeFogFactor;y.reciprocal;y.lightProjectionUV;y.reference;y.referenceBuffer;y.reflect;y.reflectVector;y.reflectView;y.reflector;y.refract;y.refractVector;y.refractView;y.reinhardToneMapping;y.remainder;y.remap;y.remapClamp;y.renderGroup;y.renderOutput;y.rendererReference;y.rotate;y.rotateUV;y.roughness;y.round;y.rtt;y.sRGBTransferEOTF;y.sRGBTransferOETF;y.sampler;y.samplerComparison;y.saturate;y.saturation;y.screen;y.screenCoordinate;y.screenSize;y.screenUV;y.scriptable;y.scriptableValue;y.select;y.setCurrentStack;y.shaderStages;y.shadow;y.pointShadow;y.shadowPositionWorld;y.sharedUniformGroup;y.shapeCircle;y.sheen;y.sheenRoughness;y.shiftLeft;y.shiftRight;y.shininess;y.sign;y.sin;y.sinc;y.skinning;y.smoothstep;y.smoothstepElement;y.specularColor;y.specularF90;y.spherizeUV;y.split;y.spritesheetUV;y.sqrt;y.stack;y.step;y.storage;y.storageBarrier;y.storageObject;y.storageTexture;y.string;y.struct;y.sub;y.subgroupIndex;y.subgroupSize;y.tan;y.tangentGeometry;y.tangentLocal;y.tangentView;y.tangentWorld;y.temp;y.texture;y.texture3D;y.textureBarrier;y.textureBicubic;y.textureCubeUV;y.textureLoad;y.textureSize;y.textureStore;y.thickness;y.time;y.timerDelta;y.timerGlobal;y.timerLocal;y.toneMapping;y.toneMappingExposure;y.toonOutlinePass;y.transformDirection;y.transformNormal;y.transformNormalToView;y.transformedBentNormalView;y.transformedBitangentView;y.transformedBitangentWorld;y.transformedClearcoatNormalView;y.transformedNormalView;y.transformedNormalWorld;y.transformedTangentView;y.transformedTangentWorld;y.transmission;y.transpose;y.triNoise3D;y.triplanarTexture;y.triplanarTextures;y.trunc;y.tslFn;y.uint;y.uniform;y.uniformCubeTexture;y.uniformArray;y.uniformGroup;y.uniformTexture;y.uniforms;y.unpremult;y.userData;y.uv;y.uvec2;y.uvec3;y.uvec4;y.Var;y.varying;y.varyingProperty;y.vec2;y.vec3;const btt=y.vec4;y.vectorComponents;y.velocity;y.vertexColor;y.vertexIndex;y.vibrance;y.viewZToLogarithmicDepth;y.viewZToOrthographicDepth;y.viewZToPerspectiveDepth;y.viewport;y.viewportBottomLeft;y.viewportCoordinate;y.viewportDepthTexture;y.viewportLinearDepth;y.viewportMipTexture;y.viewportResolution;y.viewportSafeUV;y.viewportSharedTexture;y.viewportSize;y.viewportTexture;y.viewportTopLeft;y.viewportUV;y.wgsl;y.wgslFn;y.workgroupArray;y.workgroupBarrier;y.workgroupId;y.workingToColorSpace;y.xor;const oe=Y.createContext(null),vtt=({children:r,hideNotice:t=!1,style:e={},className:s="",...i})=>{const n=Y.useRef(null),a=Y.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=Y.useRef(null);o.current===null&&(o.current=rs.shaderRenderer());const l=Y.useMemo(()=>(f,x,b,w,S=null)=>{if(x===null){try{o.current.removeNode(f)}catch(_){console.warn("Error removing node:",_)}return}try{o.current.registerNode(f,x,b,w,S)}catch(_){console.error("Error registering node:",_,{id:f,parentId:b,metadata:w})}},[]),h=Y.useMemo(()=>(f,x,b)=>{try{o.current.updateUniformValue(f,x,b)}catch(w){console.warn("Error updating uniform:",w)}},[]),u=Y.useMemo(()=>(f,x)=>{try{o.current.updateNodeMetadata(f,x)}catch(b){console.warn("Error updating metadata:",b)}},[]),c=Y.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=Y.useRef(!1),p=Y.useRef(!1);Y.useEffect(()=>{if(d.current||p.current)return;const f=n.current;if(!f)return;p.current=!0;const x=o.current;return x.initialize({canvas:f}).then(()=>{x.registerNode(a,({childNode:b})=>b||btt(0,0,0,0),null,null,{}),d.current=!0,p.current=!1,t||x.showLicenseWarning()}).catch(b=>{console.error("[Shader] Initialization failed:",b),p.current=!1}),()=>{try{x.cleanup(),d.current=!1,p.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(b){console.warn("[Shader] Error during cleanup:",b)}}},[a,t]);const m={...s===""?{width:"1200px",height:"800px"}:{},...typeof e=="object"?e:{}};return zr.jsx(oe.Provider,{value:c,children:zr.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof e=="object"?e:{}},className:s,...i,children:[zr.jsx("canvas",{"data-renderer":"ombre",ref:n,style:m}),r]})})};function wtt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const aA={blendMode:"normal",opacity:1};try{ul&&ul.props&&Object.entries(ul.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(aA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Mtt=r=>{const t=Y.useContext(oe);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=Y.useMemo(()=>r.id||`${ul.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=Y.useMemo(()=>wtt(r,aA),[r]),l=Y.useRef(null);l.current===null&&(l.current=rs.createUniformsMap(ul,o,a));const h=Y.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(Y.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,ul.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),Y.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),Y.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return zr.jsx(oe.Provider,{value:h,children:r.children})},gl={name:"FilmGrain",props:{intensity:{type:Number,default:1,description:"Grain intensity"}},fragmentNode:({uniforms:r,childNode:t})=>{let e=t||ag(0,0,0,0),s=vN(),i=s.x.add(4).mul(s.y.add(4)).mul(bN.mul(r.speed.uniform).mul(10)),n=i.mod(13).add(1),a=i.mod(123).add(1),o=n.mul(a).mod(.01).sub(.005),l=o.mul(r.intensity.uniform).mul(10);return ag(e.x.add(l),e.y.add(l),e.z.add(l),e.w)}};function Ttt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const oA={blendMode:"normal",opacity:1};try{gl&&gl.props&&Object.entries(gl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(oA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Ntt=r=>{const t=Y.useContext(oe);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=Y.useMemo(()=>r.id||`${gl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=Y.useMemo(()=>Ttt(r,oA),[r]),l=Y.useRef(null);l.current===null&&(l.current=rs.createUniformsMap(gl,o,a));const h=Y.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(Y.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,gl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),Y.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),Y.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return zr.jsx(oe.Provider,{value:h,children:r.children})},od=new WeakMap,yl={name:"glassTiles",props:{intensity:{type:Number,default:1,description:"The intensity of the glass tiles effect"},tileCount:{type:Number,default:100,description:"Number of tiles across the shortest dimension"}},fragmentNode:({uniforms:r,childNode:t,onCleanup:e,canvas:s})=>{let{vec2:i,vec4:n,floor:a,mul:o,div:l,sub:h,add:u,convertToTexture:c,uv:d,uniform:p}=ss;if(!t)return console.error("You must pass a child component into the Glass Tiles shader."),n(0);let m=c(t),f=p(1),x=()=>{s&&(f.value=s.clientWidth/s.clientHeight)};x();let b=od.get(s);b||(b=new ResizeObserver(Vt=>{let Yt=Vt[0];if(!Yt)return;let{width:se,height:te}=Yt.contentRect,ft=window.devicePixelRatio||1;m.setSize(se*ft,te*ft),x()}),b.observe(s),od.set(s,b)),e(()=>{let Vt=od.get(s);Vt&&(Vt.disconnect(),od.delete(s))});let w=d(),S=r.intensity.uniform,_=r.tileCount.uniform,V=i(f.greaterThanEqual(1).select(o(_,f),_),f.lessThan(1).select(l(_,f),_)),z=l(a(o(w,V)),V),A=h(w,z),I=i(.5,.5),et=o(S,.025),nt=l(A,l(i(1),V)),it=h(nt,I),vt=o(it,et),mt=u(A,vt),Rt=u(mt,z);return n(m.sample(Rt))}};function Stt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const lA={blendMode:"normal",opacity:1};try{yl&&yl.props&&Object.entries(yl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(lA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const _tt=r=>{const t=Y.useContext(oe);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=Y.useMemo(()=>r.id||`${yl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=Y.useMemo(()=>Stt(r,lA),[r]),l=Y.useRef(null);l.current===null&&(l.current=rs.createUniformsMap(yl,o,a));const h=Y.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(Y.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,yl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),Y.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),Y.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return zr.jsx(oe.Provider,{value:h,children:r.children})},ld={VERTEX:"vertex"},Rn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},jh=["x","y","z","w"],gr="00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff".split(".");let Bv=1234567;const uA=Math.PI/180,hA=180/Math.PI;function Nd(){let r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(gr[r&255]+gr[r>>8&255]+gr[r>>16&255]+gr[r>>24&255]+"-"+gr[t&255]+gr[t>>8&255]+"-"+gr[t>>16&15|64]+gr[t>>24&255]+"-"+gr[e&63|128]+gr[e>>8&255]+"-"+gr[e>>16&255]+gr[e>>24&255]+gr[s&255]+gr[s>>8&255]+gr[s>>16&255]+gr[s>>24&255]).toLowerCase()}function kt(r,t,e){return Math.max(t,Math.min(e,r))}function tx(r,t){return(r%t+t)%t}function Att(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function ztt(r,t,e){return r===t?0:(e-r)/(t-r)}function ku(r,t,e){return(1-e)*r+e*t}function Ctt(r,t,e,s){return ku(r,t,1-Math.exp(-e*s))}function Ett(r,t=1){return t-Math.abs(tx(r,t*2)-t)}function Vtt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Rtt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Ltt(r,t){return r+Math.floor(Math.random()*(t-r+1))}function Itt(r,t){return r+Math.random()*(t-r)}function Ptt(r){return r*(.5-Math.random())}function Ftt(r){r!==void 0&&(Bv=r);let t=Bv+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Ott(r){return r*uA}function Btt(r){return r*hA}function ktt(r){return(r&r-1)==0&&r!==0}function Dtt(r){return 2**Math.ceil(Math.log(r)/Math.LN2)}function Utt(r){return 2**Math.floor(Math.log(r)/Math.LN2)}function $tt(r,t,e,s,i){let n=Math.cos,a=Math.sin,o=n(e/2),l=a(e/2),h=n((t+s)/2),u=a((t+s)/2),c=n((t-s)/2),d=a((t-s)/2),p=n((s-t)/2),m=a((s-t)/2);switch(i){case"XYX":r.set(o*u,l*c,l*d,o*h);break;case"YZY":r.set(l*d,o*u,l*c,o*h);break;case"ZXZ":r.set(l*c,l*d,o*u,o*h);break;case"XZX":r.set(o*u,l*m,l*p,o*h);break;case"YXY":r.set(l*p,o*u,l*m,o*h);break;case"ZYZ":r.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Gs(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw Error("Invalid component type.")}}function Ht(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw Error("Invalid component type.")}}const jtt={DEG2RAD:uA,RAD2DEG:hA,generateUUID:Nd,clamp:kt,euclideanModulo:tx,mapLinear:Att,inverseLerp:ztt,lerp:ku,damp:Ctt,pingpong:Ett,smoothstep:Vtt,smootherstep:Rtt,randInt:Ltt,randFloat:Itt,randFloatSpread:Ptt,seededRandom:Ftt,degToRad:Ott,radToDeg:Btt,isPowerOfTwo:ktt,ceilPowerOfTwo:Dtt,floorPowerOfTwo:Utt,setQuaternionFromProperEuler:$tt,normalize:Ht,denormalize:Gs},Lg=0,Wtt=1015,Ig="",Us="srgb",kv="srgb-linear",Dv="linear",Du="srgb",op=35044,Ca=2e3,Pg=2001;var Wh=class cA{constructor(t,e,s,i,n,a,o,l,h){cA.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h)}set(t,e,s,i,n,a,o,l,h){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=n,u[5]=l,u[6]=s,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[3],l=s[6],h=s[1],u=s[4],c=s[7],d=s[2],p=s[5],m=s[8],f=i[0],x=i[3],b=i[6],w=i[1],S=i[4],_=i[7],V=i[2],z=i[5],A=i[8];return n[0]=a*f+o*w+l*V,n[3]=a*x+o*S+l*z,n[6]=a*b+o*_+l*A,n[1]=h*f+u*w+c*V,n[4]=h*x+u*S+c*z,n[7]=h*b+u*_+c*A,n[2]=d*f+p*w+m*V,n[5]=d*x+p*S+m*z,n[8]=d*b+p*_+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=e*c+s*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/m;return t[0]=c*f,t[1]=(i*h-u*s)*f,t[2]=(o*s-i*a)*f,t[3]=d*f,t[4]=(u*e-i*l)*f,t[5]=(i*n-o*e)*f,t[6]=p*f,t[7]=(s*l-h*e)*f,t[8]=(a*e-s*n)*f,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(s*l,s*h,-s*(l*a+h*o)+a+t,-i*h,i*l,-i*(-h*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Of.makeScale(t,e)),this}rotate(t){return this.premultiply(Of.makeRotation(-t)),this}translate(t,e){return this.premultiply(Of.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const Of=new Wh,Uv={};function $v(r){r in Uv||(Uv[r]=!0,console.warn(r))}const jv=new Wh().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Wv=new Wh().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function qtt(){let r={enabled:!0,workingColorSpace:kv,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Du&&(i.r=xl(i.r),i.g=xl(i.g),i.b=xl(i.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Du&&(i.r=bl(i.r),i.g=bl(i.g),i.b=bl(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Ig?Dv:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,a){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return $v("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return $v("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[kv]:{primaries:t,whitePoint:s,transfer:Dv,toXYZ:jv,fromXYZ:Wv,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Us},outputColorSpaceConfig:{drawingBufferColorSpace:Us}},[Us]:{primaries:t,whitePoint:s,transfer:Du,toXYZ:jv,fromXYZ:Wv,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Us}}}),r}const Oe=qtt();function xl(r){return r<.04045?r*.0773993808:(r*.9478672986+.0521327014)**2.4}function bl(r){return r<.0031308?r*12.92:1.055*r**.41666-.055}const dA={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},zn={h:0,s:0,l:0},ud={h:0,s:0,l:0};function Bf(r,t,e){return e<0&&(e+=1),e>1&&--e,e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}var ex=class{constructor(r,t,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(r,t,e)}set(r,t,e){if(t===void 0&&e===void 0){let s=r;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(r,t,e);return this}setScalar(r){return this.r=r,this.g=r,this.b=r,this}setHex(r,t=Us){return r=Math.floor(r),this.r=(r>>16&255)/255,this.g=(r>>8&255)/255,this.b=(r&255)/255,Oe.colorSpaceToWorking(this,t),this}setRGB(r,t,e,s=Oe.workingColorSpace){return this.r=r,this.g=t,this.b=e,Oe.colorSpaceToWorking(this,s),this}setHSL(r,t,e,s=Oe.workingColorSpace){if(r=tx(r,1),t=kt(t,0,1),e=kt(e,0,1),t===0)this.r=this.g=this.b=e;else{let i=e<=.5?e*(1+t):e+t-e*t,n=2*e-i;this.r=Bf(n,i,r+1/3),this.g=Bf(n,i,r),this.b=Bf(n,i,r-1/3)}return Oe.colorSpaceToWorking(this,s),this}setStyle(r,t=Us){function e(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+r+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(r)){let i,n=s[1],a=s[2];switch(n){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+r)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(r)){let i=s[1],n=i.length;if(n===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(n===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+r)}else if(r&&r.length>0)return this.setColorName(r,t);return this}setColorName(r,t=Us){let e=dA[r.toLowerCase()];return e===void 0?console.warn("THREE.Color: Unknown color "+r):this.setHex(e,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(r){return this.r=r.r,this.g=r.g,this.b=r.b,this}copySRGBToLinear(r){return this.r=xl(r.r),this.g=xl(r.g),this.b=xl(r.b),this}copyLinearToSRGB(r){return this.r=bl(r.r),this.g=bl(r.g),this.b=bl(r.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(r=Us){return Oe.workingToColorSpace(yr.copy(this),r),Math.round(kt(yr.r*255,0,255))*65536+Math.round(kt(yr.g*255,0,255))*256+Math.round(kt(yr.b*255,0,255))}getHexString(r=Us){return("000000"+this.getHex(r).toString(16)).slice(-6)}getHSL(r,t=Oe.workingColorSpace){Oe.workingToColorSpace(yr.copy(this),t);let e=yr.r,s=yr.g,i=yr.b,n=Math.max(e,s,i),a=Math.min(e,s,i),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case e:o=(s-i)/u+(s<i?6:0);break;case s:o=(i-e)/u+2;break;case i:o=(e-s)/u+4;break}o/=6}return r.h=o,r.s=l,r.l=h,r}getRGB(r,t=Oe.workingColorSpace){return Oe.workingToColorSpace(yr.copy(this),t),r.r=yr.r,r.g=yr.g,r.b=yr.b,r}getStyle(r=Us){Oe.workingToColorSpace(yr.copy(this),r);let t=yr.r,e=yr.g,s=yr.b;return r===Us?`rgb(${Math.round(t*255)},${Math.round(e*255)},${Math.round(s*255)})`:`color(${r} ${t.toFixed(3)} ${e.toFixed(3)} ${s.toFixed(3)})`}offsetHSL(r,t,e){return this.getHSL(zn),this.setHSL(zn.h+r,zn.s+t,zn.l+e)}add(r){return this.r+=r.r,this.g+=r.g,this.b+=r.b,this}addColors(r,t){return this.r=r.r+t.r,this.g=r.g+t.g,this.b=r.b+t.b,this}addScalar(r){return this.r+=r,this.g+=r,this.b+=r,this}sub(r){return this.r=Math.max(0,this.r-r.r),this.g=Math.max(0,this.g-r.g),this.b=Math.max(0,this.b-r.b),this}multiply(r){return this.r*=r.r,this.g*=r.g,this.b*=r.b,this}multiplyScalar(r){return this.r*=r,this.g*=r,this.b*=r,this}lerp(r,t){return this.r+=(r.r-this.r)*t,this.g+=(r.g-this.g)*t,this.b+=(r.b-this.b)*t,this}lerpColors(r,t,e){return this.r=r.r+(t.r-r.r)*e,this.g=r.g+(t.g-r.g)*e,this.b=r.b+(t.b-r.b)*e,this}lerpHSL(r,t){this.getHSL(zn),r.getHSL(ud);let e=ku(zn.h,ud.h,t),s=ku(zn.s,ud.s,t),i=ku(zn.l,ud.l,t);return this.setHSL(e,s,i),this}setFromVector3(r){return this.r=r.x,this.g=r.y,this.b=r.z,this}applyMatrix3(r){let t=this.r,e=this.g,s=this.b,i=r.elements;return this.r=i[0]*t+i[3]*e+i[6]*s,this.g=i[1]*t+i[4]*e+i[7]*s,this.b=i[2]*t+i[5]*e+i[8]*s,this}equals(r){return r.r===this.r&&r.g===this.g&&r.b===this.b}fromArray(r,t=0){return this.r=r[t],this.g=r[t+1],this.b=r[t+2],this}toArray(r=[],t=0){return r[t]=this.r,r[t+1]=this.g,r[t+2]=this.b,r}fromBufferAttribute(r,t){return this.r=r.getX(t),this.g=r.getY(t),this.b=r.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const yr=new ex;ex.NAMES=dA;var Htt=class pA{constructor(t,e,s,i){pA.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){let n=this.elements;return n[0]=t,n[2]=e,n[1]=s,n[3]=i,this}},Gtt=class{constructor(r=0,t=0,e=0,s=1){this.isQuaternion=!0,this._x=r,this._y=t,this._z=e,this._w=s}static slerpFlat(r,t,e,s,i,n,a){let o=e[s+0],l=e[s+1],h=e[s+2],u=e[s+3],c=i[n+0],d=i[n+1],p=i[n+2],m=i[n+3];if(a===0){r[t+0]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u;return}if(a===1){r[t+0]=c,r[t+1]=d,r[t+2]=p,r[t+3]=m;return}if(u!==m||o!==c||l!==d||h!==p){let f=1-a,x=o*c+l*d+h*p+u*m,b=x>=0?1:-1,w=1-x*x;if(w>2**-52){let _=Math.sqrt(w),V=Math.atan2(_,x*b);f=Math.sin(f*V)/_,a=Math.sin(a*V)/_}let S=a*b;if(o=o*f+c*S,l=l*f+d*S,h=h*f+p*S,u=u*f+m*S,f===1-a){let _=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=_,l*=_,h*=_,u*=_}}r[t]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u}static multiplyQuaternionsFlat(r,t,e,s,i,n){let a=e[s],o=e[s+1],l=e[s+2],h=e[s+3],u=i[n],c=i[n+1],d=i[n+2],p=i[n+3];return r[t]=a*p+h*u+o*d-l*c,r[t+1]=o*p+h*c+l*u-a*d,r[t+2]=l*p+h*d+a*c-o*u,r[t+3]=h*p-a*u-o*c-l*d,r}get x(){return this._x}set x(r){this._x=r,this._onChangeCallback()}get y(){return this._y}set y(r){this._y=r,this._onChangeCallback()}get z(){return this._z}set z(r){this._z=r,this._onChangeCallback()}get w(){return this._w}set w(r){this._w=r,this._onChangeCallback()}set(r,t,e,s){return this._x=r,this._y=t,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(r){return this._x=r.x,this._y=r.y,this._z=r.z,this._w=r.w,this._onChangeCallback(),this}setFromEuler(r,t=!0){let e=r._x,s=r._y,i=r._z,n=r._order,a=Math.cos,o=Math.sin,l=a(e/2),h=a(s/2),u=a(i/2),c=o(e/2),d=o(s/2),p=o(i/2);switch(n){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(r,t){let e=t/2,s=Math.sin(e);return this._x=r.x*s,this._y=r.y*s,this._z=r.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(r){let t=r.elements,e=t[0],s=t[4],i=t[8],n=t[1],a=t[5],o=t[9],l=t[2],h=t[6],u=t[10],c=e+a+u;if(c>0){let d=.5/Math.sqrt(c+1);this._w=.25/d,this._x=(h-o)*d,this._y=(i-l)*d,this._z=(n-s)*d}else if(e>a&&e>u){let d=2*Math.sqrt(1+e-a-u);this._w=(h-o)/d,this._x=.25*d,this._y=(s+n)/d,this._z=(i+l)/d}else if(a>u){let d=2*Math.sqrt(1+a-e-u);this._w=(i-l)/d,this._x=(s+n)/d,this._y=.25*d,this._z=(o+h)/d}else{let d=2*Math.sqrt(1+u-e-a);this._w=(n-s)/d,this._x=(i+l)/d,this._y=(o+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(r,t){let e=r.dot(t)+1;return e<2**-52?(e=0,Math.abs(r.x)>Math.abs(r.z)?(this._x=-r.y,this._y=r.x,this._z=0,this._w=e):(this._x=0,this._y=-r.z,this._z=r.y,this._w=e)):(this._x=r.y*t.z-r.z*t.y,this._y=r.z*t.x-r.x*t.z,this._z=r.x*t.y-r.y*t.x,this._w=e),this.normalize()}angleTo(r){return 2*Math.acos(Math.abs(kt(this.dot(r),-1,1)))}rotateTowards(r,t){let e=this.angleTo(r);if(e===0)return this;let s=Math.min(1,t/e);return this.slerp(r,s),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(r){return this._x*r._x+this._y*r._y+this._z*r._z+this._w*r._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 r=this.length();return r===0?(this._x=0,this._y=0,this._z=0,this._w=1):(r=1/r,this._x*=r,this._y*=r,this._z*=r,this._w*=r),this._onChangeCallback(),this}multiply(r){return this.multiplyQuaternions(this,r)}premultiply(r){return this.multiplyQuaternions(r,this)}multiplyQuaternions(r,t){let e=r._x,s=r._y,i=r._z,n=r._w,a=t._x,o=t._y,l=t._z,h=t._w;return this._x=e*h+n*a+s*l-i*o,this._y=s*h+n*o+i*a-e*l,this._z=i*h+n*l+e*o-s*a,this._w=n*h-e*a-s*o-i*l,this._onChangeCallback(),this}slerp(r,t){if(t===0)return this;if(t===1)return this.copy(r);let e=this._x,s=this._y,i=this._z,n=this._w,a=n*r._w+e*r._x+s*r._y+i*r._z;if(a<0?(this._w=-r._w,this._x=-r._x,this._y=-r._y,this._z=-r._z,a=-a):this.copy(r),a>=1)return this._w=n,this._x=e,this._y=s,this._z=i,this;let o=1-a*a;if(o<=2**-52){let d=1-t;return this._w=d*n+t*this._w,this._x=d*e+t*this._x,this._y=d*s+t*this._y,this._z=d*i+t*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,c=Math.sin(t*h)/l;return this._w=n*u+this._w*c,this._x=e*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(r,t,e){return this.copy(r).slerp(t,e)}random(){let r=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(r),s*Math.cos(r),i*Math.sin(t),i*Math.cos(t))}equals(r){return r._x===this._x&&r._y===this._y&&r._z===this._z&&r._w===this._w}fromArray(r,t=0){return this._x=r[t],this._y=r[t+1],this._z=r[t+2],this._w=r[t+3],this._onChangeCallback(),this}toArray(r=[],t=0){return r[t]=this._x,r[t+1]=this._y,r[t+2]=this._z,r[t+3]=this._w,r}fromBufferAttribute(r,t){return this._x=r.getX(t),this._y=r.getY(t),this._z=r.getZ(t),this._w=r.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(r){return this._onChangeCallback=r,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ti=class mA{constructor(t=0,e=0,s=0){mA.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(qv.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qv.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=t.elements,a=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(t){let e=this.x,s=this.y,i=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*i-o*s),u=2*(o*e-n*i),c=2*(n*s-a*e);return this.x=e+l*h+a*c-o*u,this.y=s+l*u+o*h-n*c,this.z=i+l*c+n*u-a*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let s=t.x,i=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return kf.copy(this).projectOnVector(t),this.sub(kf)}reflect(t){return this.sub(kf.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(kt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){let i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const kf=new ti,qv=new Gtt;var fA=class Fg{constructor(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){Fg.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x)}set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){let b=this.elements;return b[0]=t,b[4]=e,b[8]=s,b[12]=i,b[1]=n,b[5]=a,b[9]=o,b[13]=l,b[2]=h,b[6]=u,b[10]=c,b[14]=d,b[3]=p,b[7]=m,b[11]=f,b[15]=x,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 Fg().fromArray(this.elements)}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){let e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,s=t.elements,i=1/Wo.setFromMatrixColumn(t,0).length(),n=1/Wo.setFromMatrixColumn(t,1).length(),a=1/Wo.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,s=t.x,i=t.y,n=t.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),c=Math.sin(n);if(t.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=-l*c,e[8]=h,e[1]=p+m*h,e[5]=d-f*h,e[9]=-o*l,e[2]=f-d*h,e[6]=m+p*h,e[10]=a*l}else if(t.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d+f*o,e[4]=m*o-p,e[8]=a*h,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=p*o-m,e[6]=f+d*o,e[10]=a*l}else if(t.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d-f*o,e[4]=-a*c,e[8]=m+p*o,e[1]=p+m*o,e[5]=a*u,e[9]=f-d*o,e[2]=-a*h,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=m*h-p,e[8]=d*h+f,e[1]=l*c,e[5]=f*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=f-d*c,e[8]=m*c+p,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-h*u,e[6]=p*c+m,e[10]=d-f*c}else if(t.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=-c,e[8]=h*u,e[1]=d*c+f,e[5]=a*u,e[9]=p*c-m,e[2]=m*c-p,e[6]=o*u,e[10]=f*c+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Xtt,t,Ytt)}lookAt(t,e,s){let i=this.elements;return Wr.subVectors(t,e),Wr.lengthSq()===0&&(Wr.z=1),Wr.normalize(),Cn.crossVectors(s,Wr),Cn.lengthSq()===0&&(Math.abs(s.z)===1?Wr.x+=1e-4:Wr.z+=1e-4,Wr.normalize(),Cn.crossVectors(s,Wr)),Cn.normalize(),hd.crossVectors(Wr,Cn),i[0]=Cn.x,i[4]=hd.x,i[8]=Wr.x,i[1]=Cn.y,i[5]=hd.y,i[9]=Wr.y,i[2]=Cn.z,i[6]=hd.z,i[10]=Wr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[4],l=s[8],h=s[12],u=s[1],c=s[5],d=s[9],p=s[13],m=s[2],f=s[6],x=s[10],b=s[14],w=s[3],S=s[7],_=s[11],V=s[15],z=i[0],A=i[4],I=i[8],et=i[12],nt=i[1],it=i[5],vt=i[9],mt=i[13],Rt=i[2],Vt=i[6],Yt=i[10],se=i[14],te=i[3],ft=i[7],bt=i[11],Et=i[15];return n[0]=a*z+o*nt+l*Rt+h*te,n[4]=a*A+o*it+l*Vt+h*ft,n[8]=a*I+o*vt+l*Yt+h*bt,n[12]=a*et+o*mt+l*se+h*Et,n[1]=u*z+c*nt+d*Rt+p*te,n[5]=u*A+c*it+d*Vt+p*ft,n[9]=u*I+c*vt+d*Yt+p*bt,n[13]=u*et+c*mt+d*se+p*Et,n[2]=m*z+f*nt+x*Rt+b*te,n[6]=m*A+f*it+x*Vt+b*ft,n[10]=m*I+f*vt+x*Yt+b*bt,n[14]=m*et+f*mt+x*se+b*Et,n[3]=w*z+S*nt+_*Rt+V*te,n[7]=w*A+S*it+_*Vt+V*ft,n[11]=w*I+S*vt+_*Yt+V*bt,n[15]=w*et+S*mt+_*se+V*Et,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],c=t[6],d=t[10],p=t[14],m=t[3],f=t[7],x=t[11],b=t[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+e*l*p-e*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+x*(+e*h*c-e*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-e*l*c+e*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],d=t[10],p=t[11],m=t[12],f=t[13],x=t[14],b=t[15],w=c*x*h-f*d*h+f*l*p-o*x*p-c*l*b+o*d*b,S=m*d*h-u*x*h-m*l*p+a*x*p+u*l*b-a*d*b,_=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,V=m*c*l-u*f*l-m*o*d+a*f*d+u*o*x-a*c*x,z=e*w+s*S+i*_+n*V;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/z;return t[0]=w*A,t[1]=(f*d*n-c*x*n-f*i*p+s*x*p+c*i*b-s*d*b)*A,t[2]=(o*x*n-f*l*n+f*i*h-s*x*h-o*i*b+s*l*b)*A,t[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*A,t[4]=S*A,t[5]=(u*x*n-m*d*n+m*i*p-e*x*p-u*i*b+e*d*b)*A,t[6]=(m*l*n-a*x*n-m*i*h+e*x*h+a*i*b-e*l*b)*A,t[7]=(a*d*n-u*l*n+u*i*h-e*d*h-a*i*p+e*l*p)*A,t[8]=_*A,t[9]=(m*c*n-u*f*n-m*s*p+e*f*p+u*s*b-e*c*b)*A,t[10]=(a*f*n-m*o*n+m*s*h-e*f*h-a*s*b+e*o*b)*A,t[11]=(u*o*n-a*c*n-u*s*h+e*c*h+a*s*p-e*o*p)*A,t[12]=V*A,t[13]=(u*f*i-m*c*i+m*s*d-e*f*d-u*s*x+e*c*x)*A,t[14]=(m*o*i-a*f*i-m*s*l+e*f*l+a*s*x-e*o*x)*A,t[15]=(a*c*i-u*o*i+u*s*l-e*c*l-a*s*d+e*o*d)*A,this}scale(t){let e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let s=Math.cos(e),i=Math.sin(e),n=1-s,a=t.x,o=t.y,l=t.z,h=n*a,u=n*o;return this.set(h*a+s,h*o-i*l,h*l+i*o,0,h*o+i*l,u*o+s,u*l-i*a,0,h*l-i*o,u*l+i*a,n*l*l+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,a){return this.set(1,s,n,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){let i=this.elements,n=e._x,a=e._y,o=e._z,l=e._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,x=a*c,b=o*c,w=l*h,S=l*u,_=l*c,V=s.x,z=s.y,A=s.z;return i[0]=(1-(f+b))*V,i[1]=(p+_)*V,i[2]=(m-S)*V,i[3]=0,i[4]=(p-_)*z,i[5]=(1-(d+b))*z,i[6]=(x+w)*z,i[7]=0,i[8]=(m+S)*A,i[9]=(x-w)*A,i[10]=(1-(d+f))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){let i=this.elements,n=Wo.set(i[0],i[1],i[2]).length(),a=Wo.set(i[4],i[5],i[6]).length(),o=Wo.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Ps.copy(this);let h=1/n,u=1/a,c=1/o;return Ps.elements[0]*=h,Ps.elements[1]*=h,Ps.elements[2]*=h,Ps.elements[4]*=u,Ps.elements[5]*=u,Ps.elements[6]*=u,Ps.elements[8]*=c,Ps.elements[9]*=c,Ps.elements[10]*=c,e.setFromRotationMatrix(Ps),s.x=n,s.y=a,s.z=o,this}makePerspective(t,e,s,i,n,a,o=Ca){let l=this.elements,h=2*n/(e-t),u=2*n/(s-i),c=(e+t)/(e-t),d=(s+i)/(s-i),p,m;if(o===Ca)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===Pg)p=-a/(a-n),m=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,s,i,n,a,o=Ca){let l=this.elements,h=1/(e-t),u=1/(s-i),c=1/(a-n),d=(e+t)*h,p=(s+i)*u,m,f;if(o===Ca)m=(a+n)*c,f=-2*c;else if(o===Pg)m=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=f,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};const Wo=new ti,Ps=new fA,Xtt=new ti(0,0,0),Ytt=new ti(1,1,1),Cn=new ti,hd=new ti,Wr=new ti;var gA=class yA{constructor(t=0,e=0){yA.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(kt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*s-a*i+t.x,this.y=n*i+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ztt=class xA{constructor(t=0,e=0,s=0,i=1){xA.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w===void 0?1:t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*e+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*e+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*e+a[7]*s+a[11]*i+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n,a=.01,o=.1,l=t.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],x=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-x)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+x)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;e=Math.PI;let S=(h+1)/2,_=(p+1)/2,V=(b+1)/2,z=(u+d)/4,A=(c+f)/4,I=(m+x)/4;return S>_&&S>V?S<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(S),i=z/s,n=A/s):_>V?_<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(_),s=z/i,n=I/i):V<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(V),s=A/n,i=I/n),this.set(s,i,n,e),this}let w=Math.sqrt((x-m)*(x-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(x-m)/w,this.y=(c-f)/w,this.z=(d-u)/w,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this.w=kt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this.w=kt(this.w,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function Og(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const bA=(...r)=>Og(r);function Jtt(r,t=!1){let e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(let{property:s,childNode:i}of Bg(r))e.push(Og(s.slice(0,-4)),i.getCacheKey(t));return Og(e)}function*Bg(r,t=!1){for(let e in r){if(e.startsWith("_")===!0)continue;let s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}function kg(r){if(r==null)return null;let t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function vA(r,...t){let e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new ex(...t):e==="vec2"?new gA(...t):e==="vec3"?new ti(...t):e==="vec4"?new Ztt(...t):e==="mat2"?new Htt(...t):e==="mat3"?new Wh(...t):e==="mat4"?new fA(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?Ktt(t[0]):null}function Qtt(r){let t="",e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function Ktt(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}var tet=class{addEventListener(r,t){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[r]===void 0&&(e[r]=[]),e[r].indexOf(t)===-1&&e[r].push(t)}hasEventListener(r,t){let e=this._listeners;return e===void 0?!1:e[r]!==void 0&&e[r].indexOf(t)!==-1}removeEventListener(r,t){let e=this._listeners;if(e===void 0)return;let s=e[r];if(s!==void 0){let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}dispatchEvent(r){let t=this._listeners;if(t===void 0)return;let e=t[r.type];if(e!==void 0){r.target=this;let s=e.slice(0);for(let i=0,n=s.length;i<n;i++)s[i].call(this,r);r.target=null}}};const eet={analyze:"setup",generate:"analyze"};let ret=0;var set=class extends tet{static get type(){return"Node"}constructor(r=null){super(),this.nodeType=r,this.updateType=Rn.NONE,this.updateBeforeType=Rn.NONE,this.updateAfterType=Rn.NONE,this.uuid=jtt.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:ret++})}set needsUpdate(r){r===!0&&this.version++}get type(){return this.constructor.type}onUpdate(r,t){return this.updateType=t,this.update=r.bind(this.getSelf()),this}onFrameUpdate(r){return this.onUpdate(r,Rn.FRAME)}onRenderUpdate(r){return this.onUpdate(r,Rn.RENDER)}onObjectUpdate(r){return this.onUpdate(r,Rn.OBJECT)}onReference(r){return this.updateReference=r.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:r}of Bg(this))yield r}dispose(){this.dispatchEvent({type:"dispose"})}traverse(r){r(this);for(let t of this.getChildren())t.traverse(r)}getCacheKey(r=!1){return r||(r=this.version!==this._cacheKeyVersion),(r===!0||this._cacheKey===null)&&(this._cacheKey=bA(Jtt(this,r),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(r){let t=this.getNodeType(r);return r.getElementType(t)}getMemberType(){return"void"}getNodeType(r){let t=r.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(r):this.nodeType}getShared(r){let t=this.getHash(r);return r.getNodeFromHash(t)||this}setup(r){let t=r.getNodeProperties(this),e=0;for(let s of this.getChildren())t["node"+e++]=s;return t.outputNode||null}analyze(r,t=null){let e=r.increaseUsage(this);if(this.parents===!0){let s=r.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[r.shaderStage]=s.stages[r.shaderStage]||[],s.stages[r.shaderStage].push(t)}if(e===1){let s=r.getNodeProperties(this);for(let i of Object.values(s))i&&i.isNode===!0&&i.build(r,this)}}generate(r,t){let{outputNode:e}=r.getNodeProperties(this);if(e&&e.isNode===!0)return e.build(r,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(r,t=null){let e=this.getShared(r);if(this!==e)return e.build(r,t);let s=r.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[r.buildStage]=!0;let i=eet[r.buildStage];if(i&&s.buildStages[i]!==!0){let o=r.getBuildStage();r.setBuildStage(i),this.build(r),r.setBuildStage(o)}r.addNode(this),r.addChain(this);let n=null,a=r.getBuildStage();if(a==="setup"){this.updateReference(r);let o=r.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(r)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=r.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(r)}}n=o.outputNode}else if(a==="analyze")this.analyze(r,t);else if(a==="generate")if(this.generate.length===1){let l=this.getNodeType(r),h=r.getDataFromNode(this);n=h.snippet,n===void 0?h.generated===void 0?(h.generated=!0,n=this.generate(r)||"",h.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):h.flowCodes!==void 0&&r.context.nodeBlock!==void 0&&r.addFlowCodeHierarchy(this,r.context.nodeBlock),n=r.format(n,l,t)}else n=this.generate(r,t)||"";return r.removeChain(this),r.addSequentialNode(this),n}getSerializeChildren(){return Bg(this)}serialize(r){let t=this.getSerializeChildren(),e={};for(let{property:s,index:i,childNode:n}of t)i===void 0?e[s]=n.toJSON(r.meta).uuid:(e[s]===void 0&&(e[s]=Number.isInteger(i)?[]:{}),e[s][i]=n.toJSON(r.meta).uuid);Object.keys(e).length>0&&(r.inputNodes=e)}deserialize(r){if(r.inputNodes!==void 0){let t=r.meta.nodes;for(let e in r.inputNodes)if(Array.isArray(r.inputNodes[e])){let s=[];for(let i of r.inputNodes[e])s.push(t[i]);this[e]=s}else if(typeof r.inputNodes[e]=="object"){let s={};for(let i in r.inputNodes[e]){let n=r.inputNodes[e][i];s[i]=t[n]}this[e]=s}else{let s=r.inputNodes[e];this[e]=t[s]}}}toJSON(r){let{uuid:t,type:e}=this,s=r===void 0||typeof r=="string";s&&(r={textures:{},images:{},nodes:{}});let i=r.nodes[t];i===void 0&&(i={uuid:t,type:e,meta:r,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(r.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function n(a){let o=[];for(let l in a){let h=a[l];delete h.metadata,o.push(h)}return o}if(s){let a=n(r.textures),o=n(r.images),l=n(r.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}},$e=set,iet=class extends $e{static get type(){return"TempNode"}constructor(r=null){super(r),this.isTempNode=!0}hasDependencies(r){return r.getDataFromNode(this).usageCount>1}build(r,t){if(r.getBuildStage()==="generate"){let s=r.getVectorType(this.getNodeType(r,t)),i=r.getDataFromNode(this);if(i.propertyName!==void 0)return r.format(i.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(r)){let n=super.build(r,s),a=r.getVarFromNode(this,null,s),o=r.getPropertyName(a);return r.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,r.format(i.propertyName,s,t)}}return super.build(r,t)}},is=iet,net=class extends $e{static get type(){return"ArrayElementNode"}constructor(r,t){super(),this.node=r,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(r){return this.node.getElementType(r)}generate(r){let t=this.indexNode.getNodeType(r),e=this.node.build(r),s=this.indexNode.build(r,!r.isVector(t)&&r.isInteger(t)?t:"uint");return`${e}[ ${s} ]`}},rx=net,aet=class extends $e{static get type(){return"ConvertNode"}constructor(r,t){super(),this.node=r,this.convertTo=t}getNodeType(r){let t=this.node.getNodeType(r),e=null;for(let s of this.convertTo.split("|"))(e===null||r.getTypeLength(t)===r.getTypeLength(s))&&(e=s);return e}serialize(r){super.serialize(r),r.convertTo=this.convertTo}deserialize(r){super.deserialize(r),this.convertTo=r.convertTo}generate(r,t){let e=this.node,s=this.getNodeType(r),i=e.build(r,s);return r.format(i,s,t)}},wA=aet,oet=class extends is{static get type(){return"JoinNode"}constructor(r=[],t=null){super(t),this.nodes=r}getNodeType(r){return this.nodeType===null?r.getTypeFromLength(this.nodes.reduce((t,e)=>t+r.getTypeLength(e.getNodeType(r)),0)):r.getVectorType(this.nodeType)}generate(r,t){let e=this.getNodeType(r),s=r.getTypeLength(e),i=this.nodes,n=r.getComponentType(e),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${e}()' type.`);break}let u=h.getNodeType(r),c=r.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${e}()' data exceeds maximum length of output type.`),c=s-o,u=r.getTypeFromLength(c)),o+=c,d=h.build(r,u);let p=r.getComponentType(u);p!==n&&(d=r.format(d,p,n)),a.push(d)}let l=`${r.getType(e)}( ${a.join(", ")} )`;return r.format(l,e,t)}},uet=oet;const het=jh.join("");var cet=class extends $e{static get type(){return"SplitNode"}constructor(r,t="x"){super(),this.node=r,this.components=t,this.isSplitNode=!0}getVectorLength(){let r=this.components.length;for(let t of this.components)r=Math.max(jh.indexOf(t)+1,r);return r}getComponentType(r){return r.getComponentType(this.node.getNodeType(r))}getNodeType(r){return r.getTypeFromLength(this.components.length,this.getComponentType(r))}generate(r,t){let e=this.node,s=r.getTypeLength(e.getNodeType(r)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=r.getTypeFromLength(this.getVectorLength(),this.getComponentType(r)));let o=e.build(r,n);i=this.components.length===s&&this.components===het.slice(0,this.components.length)?r.format(o,n,t):r.format(`${o}.${this.components}`,this.getNodeType(r),t)}else i=e.build(r,t);return i}serialize(r){super.serialize(r),r.components=this.components}deserialize(r){super.deserialize(r),this.components=r.components}},Hv=cet,det=class extends is{static get type(){return"SetNode"}constructor(r,t,e){super(),this.sourceNode=r,this.components=t,this.targetNode=e}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{sourceNode:t,components:e,targetNode:s}=this,i=this.getNodeType(r),n=r.getComponentType(s.getNodeType(r)),a=r.getTypeFromLength(e.length,n),o=s.build(r,a),l=t.build(r,i),h=r.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=jh[c];d===e[0]?(u.push(o),c+=e.length-1):u.push(l+"."+d)}return`${r.getType(i)}( ${u.join(", ")} )`}},pet=det,met=class extends is{static get type(){return"FlipNode"}constructor(r,t){super(),this.sourceNode=r,this.components=t}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{components:t,sourceNode:e}=this,s=this.getNodeType(r),i=e.build(r),n=r.getVarFromNode(this),a=r.getPropertyName(n);r.addLineFlowCode(a+" = "+i,this);let o=r.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=jh[u];c===t[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${r.getType(s)}( ${l.join(", ")} )`}},fet=met,get=class extends $e{static get type(){return"InputNode"}constructor(r,t=null){super(t),this.isInputNode=!0,this.value=r,this.precision=null}getNodeType(){return this.nodeType===null?kg(this.value):this.nodeType}getInputType(r){return this.getNodeType(r)}setPrecision(r){return this.precision=r,this}serialize(r){super.serialize(r),r.value=this.value,this.value&&this.value.toArray&&(r.value=this.value.toArray()),r.valueType=kg(this.value),r.nodeType=this.nodeType,r.valueType==="ArrayBuffer"&&(r.value=Qtt(r.value)),r.precision=this.precision}deserialize(r){super.deserialize(r),this.nodeType=r.nodeType,this.value=Array.isArray(r.value)?vA(r.valueType,...r.value):r.value,this.precision=r.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(r.value))}generate(){console.warn("Abstract function.")}},sx=get;const Gv=/float|u?int/;var yet=class extends sx{static get type(){return"ConstNode"}constructor(r,t=null){super(r,t),this.isConstNode=!0}generateConst(r){return r.generateConst(this.getNodeType(r),this.value)}generate(r,t){let e=this.getNodeType(r);return Gv.test(e)&&Gv.test(t)?r.generateConst(t,this.value):r.format(this.generateConst(r),e,t)}},mn=yet,xet=class extends $e{static get type(){return"MemberNode"}constructor(r,t){super(),this.node=r,this.property=t,this.isMemberNode=!0}getNodeType(r){return this.node.getMemberType(r,this.property)}generate(r){return this.node.build(r)+"."+this.property}},bet=xet;let vet=null;const rl=new Map;function j(r,t){if(rl.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw Error(`THREE.TSL: Node element ${r} is not a function`);rl.set(r,t)}const MA=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Xv=r=>MA(r).split("").sort().join(""),TA={setup(r,t){let e=t.shift();return r(Jp(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(vet.assign(e,...s),e);if(rl.has(t)){let s=rl.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&rl.has(t.slice(0,t.length-6))){let s=rl.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=MA(t),ht(new Hv(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Xv(t.slice(3).toLowerCase()),s=>ht(new pet(r,t,ht(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Xv(t.slice(4).toLowerCase()),()=>ht(new fet(ht(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),ht(new Hv(r,t));if(/^\d+$/.test(t)===!0)return ht(new rx(e,new mn(Number(t),"uint")));if(/^get$/.test(t)===!0)return s=>ht(new bet(e,s))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},Df=new WeakMap,Yv=new WeakMap,wet=function(r,t=null){let e=kg(r);if(e==="node"){let s=Df.get(r);return s===void 0&&(s=new Proxy(r,TA),Df.set(r,s),Df.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return ht(Dg(r,t));if(e==="shader")return As(r)}return r},Met=function(r,t=null){for(let e in r)r[e]=ht(r[e],t);return r},Tet=function(r,t=null){let e=r.length;for(let s=0;s<e;s++)r[s]=ht(r[s],t);return r},Net=function(r,t=null,e=null,s=null){let i=u=>ht(s===null?u:Object.assign(u,s)),n,a=t,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:r.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return t===null?n=(...u)=>i(new r(...Sd(h(u)))):e===null?n=(...u)=>i(new r(t,...Sd(h(u)))):(e=ht(e),n=(...u)=>i(new r(t,...Sd(h(u)),e))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n};var _et=class extends $e{constructor(r,t){super(),this.shaderNode=r,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(r){return this.shaderNode.nodeType||this.getOutputNode(r).getNodeType(r)}getMemberType(r,t){return this.getOutputNode(r).getMemberType(r,t)}call(r){let{shaderNode:t,inputNodes:e}=this,s=r.getNodeProperties(t),i=t.namespace&&t.namespace===r.namespace?r.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let a=Yv.get(r.constructor);a===void 0&&(a=new WeakMap,Yv.set(r.constructor,a));let o=a.get(t);o===void 0&&(o=ht(r.buildFunctionNode(t)),a.set(t,o)),r.addInclude(o),n=ht(o.call(e))}else{let a=t.jsFunc,o=e!==null||a.length>1?a(e||[],r):a(r);n=ht(o)}return t.once&&(s[i]=n),n}setupOutput(r){return r.addStack(),r.stack.outputNode=this.call(r),r.removeStack()}getOutputNode(r){let t=r.getNodeProperties(this),e=r.getOutputNamespace();return t[e]=t[e]||this.setupOutput(r),t[e]}build(r,t=null){let e=null,s=r.getBuildStage(),i=r.getNodeProperties(this),n=r.getOutputNamespace(),a=this.getOutputNode(r);if(s==="setup"){let o=r.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(r),i[n].build(r)),e=i[n]}else s==="analyze"?a.build(r,t):s==="generate"&&(e=a.build(r,t)||"");return e}},Aet=class extends $e{constructor(r,t){super(t),this.jsFunc=r,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(r){return this.layout=r,this}call(r=null){return Jp(r),ht(new _et(this,r))}setup(){return this.call()}};const zet=[!1,!0],Cet=[0,1,2,3],Eet=[-1,-2],NA=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],ix=new Map;for(let r of zet)ix.set(r,new mn(r));const nx=new Map;for(let r of Cet)nx.set(r,new mn(r,"uint"));const ax=new Map([...nx].map(r=>new mn(r.value,"int")));for(let r of Eet)ax.set(r,new mn(r,"int"));const Yp=new Map([...ax].map(r=>new mn(r.value)));for(let r of NA)Yp.set(r,new mn(r));for(let r of NA)Yp.set(-r,new mn(-r));const Zp={bool:ix,uint:nx,ints:ax,float:Yp},Zv=new Map([...ix,...Yp]),Dg=(r,t)=>Zv.has(r)?Zv.get(r):r.isNode===!0?r:new mn(r,t),Vet=r=>{try{return r.getNodeType()}catch{return}},je=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[vA(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return ht(t.get(e[0]));if(e.length===1){let i=Dg(e[0],r);return Vet(i)===r?ht(i):ht(new wA(i,r))}let s=e.map(i=>Dg(i));return ht(new uet(s,r))}},Ret=r=>r==null?null:r.nodeType||r.convertTo||(typeof r=="string"?r:null);function Let(r,t){return new Proxy(new Aet(r,t),TA)}const ht=(r,t=null)=>wet(r,t),Jp=(r,t=null)=>new Met(r,t),Sd=(r,t=null)=>new Tet(r,t),tt=(...r)=>new Net(...r);let Iet=0;const As=(r,t=null)=>{let e=null;t!==null&&(typeof t=="object"?e=t.return:(typeof t=="string"?e=t:console.error("THREE.TSL: Invalid layout type."),t=null));let s=new Let(r,e),i=(...n)=>{let a;Jp(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return e==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),t!==null){if(typeof t.inputs!="object"){let n={name:"fn"+Iet++,type:e,inputs:[]};for(let a in t)a!=="return"&&n.inputs.push({name:a,type:t[a]});t=n}i.setLayout(t)}return i};function Pet(r){return r}j("toStack",Pet);const Fet=new je("color"),Mi=new je("float",Zp.float),ih=new je("int",Zp.ints),Oet=new je("uint",Zp.uint),Bet=new je("bool",Zp.bool),SA=new je("vec2"),ket=new je("ivec2"),Det=new je("uvec2"),Uet=new je("bvec2"),Ol=new je("vec3"),$et=new je("ivec3"),jet=new je("uvec3"),Wet=new je("bvec3"),ka=new je("vec4"),qet=new je("ivec4"),Het=new je("uvec4"),Get=new je("bvec4"),Xet=new je("mat2"),_A=new je("mat3"),Yet=new je("mat4");j("toColor",Fet),j("toFloat",Mi),j("toInt",ih),j("toUint",Oet),j("toBool",Bet),j("toVec2",SA),j("toIVec2",ket),j("toUVec2",Det),j("toBVec2",Uet),j("toVec3",Ol),j("toIVec3",$et),j("toUVec3",jet),j("toBVec3",Wet),j("toVec4",ka),j("toIVec4",qet),j("toUVec4",Het),j("toBVec4",Get),j("toMat2",Xet),j("toMat3",_A),j("toMat4",Yet);const Zet=tt(rx).setParameterLength(2),Jet=(r,t)=>ht(new wA(ht(r),t));j("element",Zet),j("convert",Jet),j("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),r));const Qet={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var Le=class Ug extends is{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new Ug(t,e,s);for(let a=0;a<i.length-1;a++)n=new Ug(t,n,i[a]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(Qet[this.op],e)}getNodeType(t){let e=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(t),a=i?i.getNodeType(t):null;if(n==="void"||a==="void")return"void";if(e==="%")return n;if(e==="~"||e==="&"||e==="|"||e==="^"||e===">>"||e==="<<")return t.getIntegerType(n);if(e==="!"||e==="&&"||e==="||"||e==="^^")return"bool";if(e==="=="||e==="!="||e==="<"||e===">"||e==="<="||e===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}}generate(t,e){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(t),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(t),l=n?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=t.changeComponentType(l,"uint")):s==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):o=t.isMatrix(l)?o==="float"?"float":t.isVector(o)?t.getVectorFromMatrix(l):l=a:l=a);let h=i.build(t,o),u=n?n.build(t,l):null,c=t.getFunctionOperator(s);if(e!=="void"){let d=t.renderer.coordinateSystem===Ca;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&t.isVector(o)?t.format(`${this.getOperatorMethod(t,e)}( ${h}, ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e);if(s==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,e):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,e);if(s==="!"||s==="~")return t.format(`(${s}${h})`,o,e);if(c)return t.format(`${c}( ${h}, ${u} )`,a,e);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${s} ${h} )`,a,e);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${s} ${u}`,a,e);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,e)}}else if(o!=="void")return c?t.format(`${c}( ${h}, ${u} )`,a,e):t.isMatrix(o)&&l==="float"?t.format(`${u} ${s} ${h}`,a,e):t.format(`${h} ${s} ${u}`,a,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}};const AA=tt(Le,"+").setParameterLength(2,1/0).setName("add"),$g=tt(Le,"-").setParameterLength(2,1/0).setName("sub"),ox=tt(Le,"*").setParameterLength(2,1/0).setName("mul"),zA=tt(Le,"/").setParameterLength(2,1/0).setName("div"),Qp=tt(Le,"%").setParameterLength(2).setName("mod"),CA=tt(Le,"==").setParameterLength(2).setName("equal"),Ket=tt(Le,"!=").setParameterLength(2).setName("notEqual"),trt=tt(Le,"<").setParameterLength(2).setName("lessThan"),ert=tt(Le,">").setParameterLength(2).setName("greaterThan"),rrt=tt(Le,"<=").setParameterLength(2).setName("lessThanEqual"),srt=tt(Le,">=").setParameterLength(2).setName("greaterThanEqual"),irt=tt(Le,"&&").setParameterLength(2,1/0).setName("and"),nrt=tt(Le,"||").setParameterLength(2,1/0).setName("or"),art=tt(Le,"!").setParameterLength(1).setName("not"),ort=tt(Le,"^^").setParameterLength(2).setName("xor"),lrt=tt(Le,"&").setParameterLength(2).setName("bitAnd"),urt=tt(Le,"~").setParameterLength(2).setName("bitNot"),hrt=tt(Le,"|").setParameterLength(2).setName("bitOr"),crt=tt(Le,"^").setParameterLength(2).setName("bitXor"),drt=tt(Le,"<<").setParameterLength(2).setName("shiftLeft"),prt=tt(Le,">>").setParameterLength(2).setName("shiftRight"),mrt=As(([r])=>(r.addAssign(1),r)),frt=As(([r])=>(r.subAssign(1),r)),grt=As(([r])=>{let t=ih(r).toConst();return r.addAssign(1),t}),yrt=As(([r])=>{let t=ih(r).toConst();return r.subAssign(1),t});j("add",AA),j("sub",$g),j("mul",ox),j("div",zA),j("mod",Qp),j("equal",CA),j("notEqual",Ket),j("lessThan",trt),j("greaterThan",ert),j("lessThanEqual",rrt),j("greaterThanEqual",srt),j("and",irt),j("or",nrt),j("not",art),j("xor",ort),j("bitAnd",lrt),j("bitNot",urt),j("bitOr",hrt),j("bitXor",crt),j("shiftLeft",drt),j("shiftRight",prt),j("incrementBefore",mrt),j("decrementBefore",frt),j("increment",grt),j("decrement",yrt);const xrt=(r,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),Qp(r,t)),brt=(r,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),Qp(ih(r),ih(t)));j("remainder",xrt),j("modInt",brt);var O=class re extends is{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){if(super(),(t===re.MAX||t===re.MIN)&&arguments.length>3){let n=new re(t,e,s);for(let a=2;a<arguments.length-1;a++)n=new re(t,n,arguments[a]);e=n,s=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),a=t.isMatrix(s)?0:t.getTypeLength(s),o=t.isMatrix(i)?0:t.getTypeLength(i);return n>a&&n>o?e:a>o?s:o>n?i:e}getNodeType(t){let e=this.method;return e===re.LENGTH||e===re.DISTANCE||e===re.DOT?"float":e===re.CROSS?"vec3":e===re.ALL||e===re.ANY?"bool":e===re.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:s,method:i}=this,n=null;if(i===re.ONE_MINUS)n=$g(1,e);else if(i===re.RECIPROCAL)n=zA(1,e);else if(i===re.DIFFERENCE)n=lx($g(e,s));else if(i===re.TRANSFORM_DIRECTION){let a=e,o=s;t.isMatrix(a.getNodeType(t))?o=ka(Ol(o),0):a=ka(Ol(a),0);let l=ox(a,o).xyz;n=EA(l)}return n===null?super.setup(t):n}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,n=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,l=this.bNode,h=this.cNode,u=t.renderer.coordinateSystem;if(i===re.NEGATE)return t.format("( - "+o.build(t,a)+" )",n,e);{let c=[];return i===re.CROSS?c.push(o.build(t,n),l.build(t,n)):u===Ca&&i===re.STEP?c.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":a),l.build(t,a)):u===Ca&&(i===re.MIN||i===re.MAX)?c.push(o.build(t,a),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":a)):i===re.REFRACT?c.push(o.build(t,a),l.build(t,a),h.build(t,"float")):i===re.MIX?c.push(o.build(t,a),l.build(t,a),h.build(t,t.getTypeLength(h.getNodeType(t))===1?"float":a)):(u===Pg&&i===re.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===re.DFDX||i===re.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(t,a)),l!==null&&c.push(l.build(t,a)),h!==null&&c.push(h.build(t,a))),t.format(`${t.getMethod(i,n)}( ${c.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};O.ALL="all",O.ANY="any",O.RADIANS="radians",O.DEGREES="degrees",O.EXP="exp",O.EXP2="exp2",O.LOG="log",O.LOG2="log2",O.SQRT="sqrt",O.INVERSE_SQRT="inversesqrt",O.FLOOR="floor",O.CEIL="ceil",O.NORMALIZE="normalize",O.FRACT="fract",O.SIN="sin",O.COS="cos",O.TAN="tan",O.ASIN="asin",O.ACOS="acos",O.ATAN="atan",O.ABS="abs",O.SIGN="sign",O.LENGTH="length",O.NEGATE="negate",O.ONE_MINUS="oneMinus",O.DFDX="dFdx",O.DFDY="dFdy",O.ROUND="round",O.RECIPROCAL="reciprocal",O.TRUNC="trunc",O.FWIDTH="fwidth",O.TRANSPOSE="transpose",O.BITCAST="bitcast",O.EQUALS="equals",O.MIN="min",O.MAX="max",O.STEP="step",O.REFLECT="reflect",O.DISTANCE="distance",O.DIFFERENCE="difference",O.DOT="dot",O.CROSS="cross",O.POW="pow",O.TRANSFORM_DIRECTION="transformDirection",O.MIX="mix",O.CLAMP="clamp",O.REFRACT="refract",O.SMOOTHSTEP="smoothstep",O.FACEFORWARD="faceforward";const vrt=Mi(Math.PI);Mi(Math.PI*2);const wrt=tt(O,O.ALL).setParameterLength(1),Mrt=tt(O,O.ANY).setParameterLength(1),Trt=tt(O,O.RADIANS).setParameterLength(1),Nrt=tt(O,O.DEGREES).setParameterLength(1),Srt=tt(O,O.EXP).setParameterLength(1),_rt=tt(O,O.EXP2).setParameterLength(1),Art=tt(O,O.LOG).setParameterLength(1),zrt=tt(O,O.LOG2).setParameterLength(1),Crt=tt(O,O.SQRT).setParameterLength(1),Ert=tt(O,O.INVERSE_SQRT).setParameterLength(1),Vrt=tt(O,O.FLOOR).setParameterLength(1),Rrt=tt(O,O.CEIL).setParameterLength(1),EA=tt(O,O.NORMALIZE).setParameterLength(1),VA=tt(O,O.FRACT).setParameterLength(1),RA=tt(O,O.SIN).setParameterLength(1),Lrt=tt(O,O.COS).setParameterLength(1),Irt=tt(O,O.TAN).setParameterLength(1),Prt=tt(O,O.ASIN).setParameterLength(1),Frt=tt(O,O.ACOS).setParameterLength(1),LA=tt(O,O.ATAN).setParameterLength(1,2),lx=tt(O,O.ABS).setParameterLength(1),IA=tt(O,O.SIGN).setParameterLength(1),Ort=tt(O,O.LENGTH).setParameterLength(1),Brt=tt(O,O.NEGATE).setParameterLength(1),krt=tt(O,O.ONE_MINUS).setParameterLength(1),Drt=tt(O,O.DFDX).setParameterLength(1),Urt=tt(O,O.DFDY).setParameterLength(1),$rt=tt(O,O.ROUND).setParameterLength(1),jrt=tt(O,O.RECIPROCAL).setParameterLength(1),Wrt=tt(O,O.TRUNC).setParameterLength(1),qrt=tt(O,O.FWIDTH).setParameterLength(1),Hrt=tt(O,O.TRANSPOSE).setParameterLength(1),Grt=(r,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),CA(r,t)),Xrt=tt(O,O.MIN).setParameterLength(2,1/0),Yrt=tt(O,O.MAX).setParameterLength(2,1/0),Zrt=tt(O,O.STEP).setParameterLength(2),Jrt=tt(O,O.REFLECT).setParameterLength(2),Qrt=tt(O,O.DISTANCE).setParameterLength(2),Krt=tt(O,O.DIFFERENCE).setParameterLength(2),qh=tt(O,O.DOT).setParameterLength(2),tst=tt(O,O.CROSS).setParameterLength(2),PA=tt(O,O.POW).setParameterLength(2),est=tt(O,O.POW,2).setParameterLength(1),rst=tt(O,O.POW,3).setParameterLength(1),sst=tt(O,O.POW,4).setParameterLength(1),ist=tt(O,O.TRANSFORM_DIRECTION).setParameterLength(2),nst=r=>ox(IA(r),PA(lx(r),1/3)),ast=r=>qh(r,r),Kp=tt(O,O.MIX).setParameterLength(3),FA=(r,t=0,e=1)=>ht(new O(O.CLAMP,ht(r),ht(t),ht(e))),ost=r=>FA(r),lst=tt(O,O.REFRACT).setParameterLength(3),ust=tt(O,O.SMOOTHSTEP).setParameterLength(3),hst=tt(O,O.FACEFORWARD).setParameterLength(3),cst=As(([r])=>{let t=12.9898,e=78.233,s=43758.5453,i=qh(r.xy,SA(t,e)),n=Qp(i,vrt);return VA(RA(n).mul(s))}),dst=(r,t,e)=>Kp(t,e,r),pst=(r,t,e)=>ust(t,e,r),mst=(r,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),LA(r,t));j("all",wrt),j("any",Mrt),j("equals",Grt),j("radians",Trt),j("degrees",Nrt),j("exp",Srt),j("exp2",_rt),j("log",Art),j("log2",zrt),j("sqrt",Crt),j("inverseSqrt",Ert),j("floor",Vrt),j("ceil",Rrt),j("normalize",EA),j("fract",VA),j("sin",RA),j("cos",Lrt),j("tan",Irt),j("asin",Prt),j("acos",Frt),j("atan",LA),j("abs",lx),j("sign",IA),j("length",Ort),j("lengthSq",ast),j("negate",Brt),j("oneMinus",krt),j("dFdx",Drt),j("dFdy",Urt),j("round",$rt),j("reciprocal",jrt),j("trunc",Wrt),j("fwidth",qrt),j("atan2",mst),j("min",Xrt),j("max",Yrt),j("step",Zrt),j("reflect",Jrt),j("distance",Qrt),j("dot",qh),j("cross",tst),j("pow",PA),j("pow2",est),j("pow3",rst),j("pow4",sst),j("transformDirection",ist),j("mix",dst),j("clamp",FA),j("refract",lst),j("smoothstep",pst),j("faceForward",hst),j("difference",Krt),j("saturate",ost),j("cbrt",nst),j("transpose",Hrt),j("rand",cst);var Jv=class extends is{static get type(){return"ArrayNode"}constructor(r,t,e=null){super(r),this.count=t,this.values=e,this.isArrayNode=!0}getNodeType(r){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(r)),this.nodeType}getElementType(r){return this.getNodeType(r)}generate(r){let t=this.getNodeType(r);return r.generateArray(t,this.count,this.values)}};const fst=(...r)=>{let t;if(r.length===1){let e=r[0];t=new Jv(null,e.length,e)}else{let e=r[0],s=r[1];t=new Jv(e,s)}return ht(t)};j("toArray",(r,t)=>fst(Array(t).fill(r)));var OA=class extends $e{static get type(){return"UniformGroupNode"}constructor(r,t=!1,e=1){super("string"),this.name=r,this.shared=t,this.order=e,this.isUniformGroup=!0}serialize(r){super.serialize(r),r.name=this.name,r.version=this.version,r.shared=this.shared}deserialize(r){super.deserialize(r),this.name=r.name,this.version=r.version,this.shared=r.shared}};const gst=r=>new OA(r),yst=(r,t=0)=>new OA(r,!0,t),xst=yst("render"),bst=gst("object");var vst=class extends sx{static get type(){return"UniformNode"}constructor(r,t=null){super(r,t),this.isUniformNode=!0,this.name="",this.groupNode=bst}label(r){return this.name=r,this}setGroup(r){return this.groupNode=r,this}getGroup(){return this.groupNode}getUniformHash(r){return this.getHash(r)}onUpdate(r,t){let e=this.getSelf();return r=r.bind(e),super.onUpdate(s=>{let i=r(s,e);i!==void 0&&(this.value=i)},t)}generate(r,t){let e=this.getNodeType(r),s=this.getUniformHash(r),i=r.getNodeFromHash(s);i===void 0&&(r.setHashNode(this,s),i=this);let n=i.getInputType(r),a=r.getUniformFromNode(i,n,r.shaderStage,this.name||r.context.label),o=r.getPropertyName(a);return r.context.label!==void 0&&delete r.context.label,r.format(o,e,t)}};const wst=(r,t)=>{let e=Ret(t||r),s=r;return ht(new vst(s,e))};var Mst=class extends $e{static get type(){return"PropertyNode"}constructor(r,t=null,e=!1){super(r),this.name=t,this.varying=e,this.isPropertyNode=!0,this.global=!0}getHash(r){return this.name||super.getHash(r)}generate(r){let t;return this.varying===!0?(t=r.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=r.getVarFromNode(this,this.name),r.getPropertyName(t)}};const Tst=(r,t)=>ht(new Mst(r,t));var Nst=class extends is{static get type(){return"AssignNode"}constructor(r,t){super(),this.targetNode=r,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(r,t){return t==="void"?"void":this.targetNode.getNodeType(r)}needsSplitAssign(r){let{targetNode:t}=this;if(r.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let e=r.getTypeLength(t.node.getNodeType(r));return jh.join("").slice(0,e)!==t.components}return!1}setup(r){let{targetNode:t,sourceNode:e}=this,s=r.getNodeProperties(this);s.sourceNode=e,s.targetNode=t.context({assign:!0})}generate(r,t){let{targetNode:e,sourceNode:s}=r.getNodeProperties(this),i=this.needsSplitAssign(r),n=e.getNodeType(r),a=e.build(r),o=s.build(r,n),l=s.getNodeType(r),h=r.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=a);else if(i){let c=r.getVarFromNode(this,null,n),d=r.getPropertyName(c);r.addLineFlowCode(`${d} = ${o}`,this);let p=e.node,m=p.node.context({assign:!0}),f=m.build(r);for(let x=0;x<p.components.length;x++){let b=p.components[x];r.addLineFlowCode(`${f}.${b} = ${d}[ ${x} ]`,this)}t!=="void"&&(u=a)}else u=`${a} = ${o}`,(t==="void"||l==="void")&&(r.addLineFlowCode(u,this),t!=="void"&&(u=a));return h.initialized=!0,r.format(u,n,t)}};const Sst=tt(Nst).setParameterLength(2);j("assign",Sst);var _st=class extends is{static get type(){return"FunctionCallNode"}constructor(r=null,t={}){super(),this.functionNode=r,this.parameters=t}setParameters(r){return this.parameters=r,this}getParameters(){return this.parameters}getNodeType(r){return this.functionNode.getNodeType(r)}generate(r){let t=[],e=this.functionNode,s=e.getInputs(r),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(r):o.build(r,h),c};if(Array.isArray(i)){if(i.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=s.length;else if(i.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<s.length;)i.push(Mi(0));for(let o=0;o<i.length;o++)t.push(n(i[o],s[o]))}else for(let o of s){let l=i[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),t.push(n(Mi(0),o))):t.push(n(l,o))}return`${e.build(r,"property")}( ${t.join(", ")} )`}};const Ast=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Sd(t):Jp(t[0]),ht(new _st(ht(r),t)));j("call",Ast);var zst=class extends $e{static get type(){return"ConditionalNode"}constructor(r,t,e=null){super(),this.condNode=r,this.ifNode=t,this.elseNode=e}getNodeType(r){let{ifNode:t,elseNode:e}=r.getNodeProperties(this);if(t===void 0)return this.setup(r),this.getNodeType(r);let s=t.getNodeType(r);if(e!==null){let i=e.getNodeType(r);if(r.getTypeLength(i)>r.getTypeLength(s))return i}return s}setup(r){let t=this.condNode.cache(),e=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=r.context.nodeBlock;r.getDataFromNode(e).parentNodeBlock=i,s!==null&&(r.getDataFromNode(s).parentNodeBlock=i);let n=r.getNodeProperties(this);n.condNode=t,n.ifNode=e.context({nodeBlock:e}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(r,t){let e=this.getNodeType(r),s=r.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=r.getNodeProperties(this),o=r.currentFunctionNode,l=t!=="void",h=l?Tst(e).build(r):"";s.nodeProperty=h;let u=i.build(r,"bool");r.addFlowCode(`
|
|
150
|
+
*/y.BRDF_GGX;y.BRDF_Lambert;y.BasicShadowFilter;y.Break;y.Continue;y.DFGApprox;y.D_GGX;y.Discard;y.EPSILON;y.F_Schlick;y.Fn;y.INFINITY;y.If;y.Switch;y.Loop;y.NodeShaderStage;y.NodeType;y.NodeUpdateType;y.NodeAccess;y.PCFShadowFilter;y.PCFSoftShadowFilter;y.PI;y.PI2;y.Return;y.Schlick_to_F0;y.ScriptableNodeResources;y.ShaderNode;y.TBNViewMatrix;y.VSMShadowFilter;y.V_GGX_SmithCorrelated;y.abs;y.acesFilmicToneMapping;y.acos;y.add;y.addNodeElement;y.agxToneMapping;y.all;y.alphaT;y.and;y.anisotropy;y.anisotropyB;y.anisotropyT;y.any;y.append;y.array;y.arrayBuffer;y.asin;y.assign;y.atan;y.atan2;y.atomicAdd;y.atomicAnd;y.atomicFunc;y.atomicMax;y.atomicMin;y.atomicOr;y.atomicStore;y.atomicSub;y.atomicXor;y.atomicLoad;y.attenuationColor;y.attenuationDistance;y.attribute;y.attributeArray;y.backgroundBlurriness;y.backgroundIntensity;y.backgroundRotation;y.batch;y.billboarding;y.bitAnd;y.bitNot;y.bitOr;y.bitXor;y.bitangentGeometry;y.bitangentLocal;y.bitangentView;y.bitangentWorld;y.bitcast;y.blendBurn;y.blendColor;y.blendDodge;y.blendOverlay;y.blendScreen;y.blur;y.bool;y.buffer;y.bufferAttribute;y.bumpMap;y.burn;y.bvec2;y.bvec3;y.bvec4;y.bypass;y.cache;y.call;y.cameraFar;y.cameraIndex;y.cameraNear;y.cameraNormalMatrix;y.cameraPosition;y.cameraProjectionMatrix;y.cameraProjectionMatrixInverse;y.cameraViewMatrix;y.cameraWorldMatrix;y.cbrt;y.cdl;y.ceil;y.checker;y.cineonToneMapping;y.clamp;y.clearcoat;y.clearcoatRoughness;y.code;y.color;y.colorSpaceToWorking;y.colorToDirection;y.compute;y.computeSkinning;y.cond;y.Const;y.context;y.convert;y.convertColorSpace;y.convertToTexture;y.cos;y.cross;y.cubeTexture;y.dFdx;y.dFdy;y.dashSize;y.debug;y.decrement;y.decrementBefore;y.defaultBuildStages;y.defaultShaderStages;y.defined;y.degrees;y.deltaTime;y.densityFog;y.densityFogFactor;y.depth;y.depthPass;y.difference;y.diffuseColor;y.directPointLight;y.directionToColor;y.dispersion;y.distance;y.div;y.dodge;y.dot;y.drawIndex;y.dynamicBufferAttribute;y.element;y.emissive;y.equal;y.equals;y.equirectUV;y.exp;y.exp2;y.expression;y.faceDirection;y.faceForward;y.faceforward;y.float;y.floor;y.fog;y.fract;y.frameGroup;y.frameId;y.frontFacing;y.fwidth;y.gain;y.gapSize;y.getConstNodeType;y.getCurrentStack;y.getDirection;y.getDistanceAttenuation;y.getGeometryRoughness;y.getNormalFromDepth;y.getParallaxCorrectNormal;y.getRoughness;y.getScreenPosition;y.getShIrradianceAt;y.getTextureIndex;y.getViewPosition;y.getShadowMaterial;y.getShadowRenderObjectFunction;y.glsl;y.glslFn;y.grayscale;y.greaterThan;y.greaterThanEqual;y.hash;y.highpModelNormalViewMatrix;y.highpModelViewMatrix;y.hue;y.increment;y.incrementBefore;y.instance;y.instanceIndex;y.instancedArray;y.instancedBufferAttribute;y.instancedDynamicBufferAttribute;y.instancedMesh;y.int;y.inverseSqrt;y.inversesqrt;y.invocationLocalIndex;y.invocationSubgroupIndex;y.ior;y.iridescence;y.iridescenceIOR;y.iridescenceThickness;y.ivec2;y.ivec3;y.ivec4;y.js;y.label;y.length;y.lengthSq;y.lessThan;y.lessThanEqual;y.lightPosition;y.lightShadowMatrix;y.lightTargetDirection;y.lightTargetPosition;y.lightViewPosition;y.lightingContext;y.lights;y.linearDepth;y.linearToneMapping;y.localId;y.globalId;y.log;y.log2;y.logarithmicDepthToViewZ;y.loop;y.luminance;y.mediumpModelViewMatrix;y.mat2;y.mat3;y.mat4;y.matcapUV;y.materialAO;y.materialAlphaTest;y.materialAnisotropy;y.materialAnisotropyVector;y.materialAttenuationColor;y.materialAttenuationDistance;y.materialClearcoat;y.materialClearcoatNormal;y.materialClearcoatRoughness;y.materialColor;y.materialDispersion;y.materialEmissive;y.materialIOR;y.materialIridescence;y.materialIridescenceIOR;y.materialIridescenceThickness;y.materialLightMap;y.materialLineDashOffset;y.materialLineDashSize;y.materialLineGapSize;y.materialLineScale;y.materialLineWidth;y.materialMetalness;y.materialNormal;y.materialOpacity;y.materialPointSize;y.materialReference;y.materialReflectivity;y.materialRefractionRatio;y.materialRotation;y.materialRoughness;y.materialSheen;y.materialSheenRoughness;y.materialShininess;y.materialSpecular;y.materialSpecularColor;y.materialSpecularIntensity;y.materialSpecularStrength;y.materialThickness;y.materialTransmission;y.max;y.maxMipLevel;y.metalness;y.min;y.mix;y.mixElement;y.mod;y.modInt;y.modelDirection;y.modelNormalMatrix;y.modelPosition;y.modelRadius;y.modelScale;y.modelViewMatrix;y.modelViewPosition;y.modelViewProjection;y.modelWorldMatrix;y.modelWorldMatrixInverse;y.morphReference;y.mrt;y.mul;y.mx_aastep;y.mx_cell_noise_float;y.mx_contrast;y.mx_fractal_noise_float;y.mx_fractal_noise_vec2;y.mx_fractal_noise_vec3;y.mx_fractal_noise_vec4;y.mx_hsvtorgb;y.mx_noise_float;y.mx_noise_vec3;y.mx_noise_vec4;y.mx_ramplr;y.mx_ramptb;y.mx_rgbtohsv;y.mx_safepower;y.mx_splitlr;y.mx_splittb;y.mx_srgb_texture_to_lin_rec709;y.mx_transform_uv;y.mx_worley_noise_float;y.mx_worley_noise_vec2;y.mx_worley_noise_vec3;y.namespace;y.negate;y.neutralToneMapping;y.nodeArray;y.nodeImmutable;y.nodeObject;y.nodeObjects;y.nodeProxy;y.normalFlat;y.normalGeometry;y.normalLocal;y.normalMap;y.normalView;y.normalWorld;y.normalize;y.not;y.notEqual;y.numWorkgroups;y.objectDirection;y.objectGroup;y.objectPosition;y.objectRadius;y.objectScale;y.objectViewPosition;y.objectWorldMatrix;y.oneMinus;y.or;y.orthographicDepthToViewZ;y.oscSawtooth;y.oscSine;y.oscSquare;y.oscTriangle;y.output;y.outputStruct;y.overlay;y.overloadingFn;y.parabola;y.parallaxDirection;y.parallaxUV;y.parameter;y.pass;y.passTexture;y.pcurve;y.perspectiveDepthToViewZ;y.pmremTexture;y.pointUV;y.pointWidth;y.positionGeometry;y.positionLocal;y.positionPrevious;y.positionView;y.positionViewDirection;y.positionWorld;y.positionWorldDirection;y.posterize;y.pow;y.pow2;y.pow3;y.pow4;y.premult;y.property;y.radians;y.rand;y.range;y.rangeFog;y.rangeFogFactor;y.reciprocal;y.lightProjectionUV;y.reference;y.referenceBuffer;y.reflect;y.reflectVector;y.reflectView;y.reflector;y.refract;y.refractVector;y.refractView;y.reinhardToneMapping;y.remainder;y.remap;y.remapClamp;y.renderGroup;y.renderOutput;y.rendererReference;y.rotate;y.rotateUV;y.roughness;y.round;y.rtt;y.sRGBTransferEOTF;y.sRGBTransferOETF;y.sampler;y.samplerComparison;y.saturate;y.saturation;y.screen;y.screenCoordinate;y.screenSize;y.screenUV;y.scriptable;y.scriptableValue;y.select;y.setCurrentStack;y.shaderStages;y.shadow;y.pointShadow;y.shadowPositionWorld;y.sharedUniformGroup;y.shapeCircle;y.sheen;y.sheenRoughness;y.shiftLeft;y.shiftRight;y.shininess;y.sign;y.sin;y.sinc;y.skinning;y.smoothstep;y.smoothstepElement;y.specularColor;y.specularF90;y.spherizeUV;y.split;y.spritesheetUV;y.sqrt;y.stack;y.step;y.storage;y.storageBarrier;y.storageObject;y.storageTexture;y.string;y.struct;y.sub;y.subgroupIndex;y.subgroupSize;y.tan;y.tangentGeometry;y.tangentLocal;y.tangentView;y.tangentWorld;y.temp;y.texture;y.texture3D;y.textureBarrier;y.textureBicubic;y.textureCubeUV;y.textureLoad;y.textureSize;y.textureStore;y.thickness;y.time;y.timerDelta;y.timerGlobal;y.timerLocal;y.toneMapping;y.toneMappingExposure;y.toonOutlinePass;y.transformDirection;y.transformNormal;y.transformNormalToView;y.transformedBentNormalView;y.transformedBitangentView;y.transformedBitangentWorld;y.transformedClearcoatNormalView;y.transformedNormalView;y.transformedNormalWorld;y.transformedTangentView;y.transformedTangentWorld;y.transmission;y.transpose;y.triNoise3D;y.triplanarTexture;y.triplanarTextures;y.trunc;y.tslFn;y.uint;y.uniform;y.uniformCubeTexture;y.uniformArray;y.uniformGroup;y.uniformTexture;y.uniforms;y.unpremult;y.userData;y.uv;y.uvec2;y.uvec3;y.uvec4;y.Var;y.varying;y.varyingProperty;y.vec2;y.vec3;const btt=y.vec4;y.vectorComponents;y.velocity;y.vertexColor;y.vertexIndex;y.vibrance;y.viewZToLogarithmicDepth;y.viewZToOrthographicDepth;y.viewZToPerspectiveDepth;y.viewport;y.viewportBottomLeft;y.viewportCoordinate;y.viewportDepthTexture;y.viewportLinearDepth;y.viewportMipTexture;y.viewportResolution;y.viewportSafeUV;y.viewportSharedTexture;y.viewportSize;y.viewportTexture;y.viewportTopLeft;y.viewportUV;y.wgsl;y.wgslFn;y.workgroupArray;y.workgroupBarrier;y.workgroupId;y.workingToColorSpace;y.xor;const oe=Y.createContext(null),vtt=({children:r,hideNotice:t=!1,style:e={},className:s="",...i})=>{const n=Y.useRef(null),a=Y.useMemo(()=>"ombre-root-"+Math.random().toString(36).substring(7),[]),o=Y.useRef(null);o.current===null&&(o.current=rs.shaderRenderer());const l=Y.useMemo(()=>(f,x,b,w,S=null)=>{if(x===null){try{o.current.removeNode(f)}catch(_){console.warn("Error removing node:",_)}return}try{o.current.registerNode(f,x,b,w,S)}catch(_){console.error("Error registering node:",_,{id:f,parentId:b,metadata:w})}},[]),h=Y.useMemo(()=>(f,x,b)=>{try{o.current.updateUniformValue(f,x,b)}catch(w){console.warn("Error updating uniform:",w)}},[]),u=Y.useMemo(()=>(f,x)=>{try{o.current.updateNodeMetadata(f,x)}catch(b){console.warn("Error updating metadata:",b)}},[]),c=Y.useMemo(()=>({ombreParentId:a,ombreNodeRegister:l,ombreUniformUpdate:h,ombreMetadataUpdate:u}),[a,l,h,u]),d=Y.useRef(!1),p=Y.useRef(!1);Y.useEffect(()=>{if(d.current||p.current)return;const f=n.current;if(!f)return;p.current=!0;const x=o.current;return x.initialize({canvas:f}).then(()=>{x.registerNode(a,({childNode:b})=>b||btt(0,0,0,0),null,null,{}),d.current=!0,p.current=!1,t||x.showLicenseWarning()}).catch(b=>{console.error("[Shader] Initialization failed:",b),p.current=!1}),()=>{try{x.cleanup(),d.current=!1,p.current=!1,console.log("[Shader] Renderer cleaned up successfully")}catch(b){console.warn("[Shader] Error during cleanup:",b)}}},[a,t]);const m={...s===""?{width:"1200px",height:"800px"}:{},...typeof e=="object"?e:{}};return zr.jsx(oe.Provider,{value:c,children:zr.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",...typeof e=="object"?e:{}},className:s,...i,children:[zr.jsx("canvas",{"data-renderer":"ombre",ref:n,style:m}),r]})})};function wtt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const aA={blendMode:"normal",opacity:1};try{ul&&ul.props&&Object.entries(ul.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(aA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Mtt=r=>{const t=Y.useContext(oe);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=Y.useMemo(()=>r.id||`${ul.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=Y.useMemo(()=>wtt(r,aA),[r]),l=Y.useRef(null);l.current===null&&(l.current=rs.createUniformsMap(ul,o,a));const h=Y.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(Y.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,ul.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),Y.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),Y.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return zr.jsx(oe.Provider,{value:h,children:r.children})},gl={name:"FilmGrain",props:{intensity:{type:Number,default:1,description:"Grain intensity"}},fragmentNode:({uniforms:r,childNode:t})=>{let e=t||ag(0,0,0,0),s=vN(),i=s.x.add(4).mul(s.y.add(4)).mul(bN.mul(10)),n=i.mod(13).add(1),a=i.mod(123).add(1),o=n.mul(a).mod(.01).sub(.005),l=o.mul(r.intensity.uniform).mul(10);return ag(e.x.add(l),e.y.add(l),e.z.add(l),e.w)}};function Ttt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const oA={blendMode:"normal",opacity:1};try{gl&&gl.props&&Object.entries(gl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(oA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const Ntt=r=>{const t=Y.useContext(oe);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=Y.useMemo(()=>r.id||`${gl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=Y.useMemo(()=>Ttt(r,oA),[r]),l=Y.useRef(null);l.current===null&&(l.current=rs.createUniformsMap(gl,o,a));const h=Y.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(Y.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,gl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),Y.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),Y.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return zr.jsx(oe.Provider,{value:h,children:r.children})},od=new WeakMap,yl={name:"glassTiles",props:{intensity:{type:Number,default:1,description:"The intensity of the glass tiles effect"},tileCount:{type:Number,default:100,description:"Number of tiles across the shortest dimension"}},fragmentNode:({uniforms:r,childNode:t,onCleanup:e,canvas:s})=>{let{vec2:i,vec4:n,floor:a,mul:o,div:l,sub:h,add:u,convertToTexture:c,uv:d,uniform:p}=ss;if(!t)return console.error("You must pass a child component into the Glass Tiles shader."),n(0);let m=c(t),f=p(1),x=()=>{s&&(f.value=s.clientWidth/s.clientHeight)};x();let b=od.get(s);b||(b=new ResizeObserver(Vt=>{let Yt=Vt[0];if(!Yt)return;let{width:se,height:te}=Yt.contentRect,ft=window.devicePixelRatio||1;m.setSize(se*ft,te*ft),x()}),b.observe(s),od.set(s,b)),e(()=>{let Vt=od.get(s);Vt&&(Vt.disconnect(),od.delete(s))});let w=d(),S=r.intensity.uniform,_=r.tileCount.uniform,V=i(f.greaterThanEqual(1).select(o(_,f),_),f.lessThan(1).select(l(_,f),_)),z=l(a(o(w,V)),V),A=h(w,z),I=i(.5,.5),et=o(S,.025),nt=l(A,l(i(1),V)),it=h(nt,I),vt=o(it,et),mt=u(A,vt),Rt=u(mt,z);return n(m.sample(Rt))}};function Stt(r,t){let e={...t};for(const[s,i]of Object.entries(r))s!=="children"&&s!=="ref"&&i!==void 0&&(e[s]=i);return e}const lA={blendMode:"normal",opacity:1};try{yl&&yl.props&&Object.entries(yl.props).forEach(([r,t])=>{const e=t;e&&typeof e=="object"&&"default"in e&&(lA[r]=e.default)})}catch(r){console.warn("Error extracting default props:",r)}const _tt=r=>{const t=Y.useContext(oe);if(!t)throw new Error("Shader components must be used inside an <Shader> component or another shader component");const{ombreParentId:e,ombreNodeRegister:s,ombreUniformUpdate:i,ombreMetadataUpdate:n}=t,a=Y.useMemo(()=>r.id||`${yl.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`,[r.id]),o=Y.useMemo(()=>Stt(r,lA),[r]),l=Y.useRef(null);l.current===null&&(l.current=rs.createUniformsMap(yl,o,a));const h=Y.useMemo(()=>({...t,ombreParentId:a}),[t,a]);if(Y.useEffect(()=>{if(l.current)try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};return s(a,yl.fragmentNode,e,u,l.current),()=>{s(a,null,null,null,null)}}catch(u){return console.error("Error registering shader node:",u),()=>{}}},[a,e,s,r.blendMode,r.opacity,r.id,r.maskSource,r.maskType]),Y.useEffect(()=>{if(l.current)try{Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u];d.value=p?p(m):m}}),Object.entries(l.current).forEach(([u,c])=>{if(!c||typeof c!="object")return;const{uniform:d,transform:p}=c;if(d?.value!==void 0&&u in o){const m=o[u],f=p?p(m):m;i(a,u,f)}})}catch(u){console.error("Error updating uniforms:",u)}},[o,a,i]),Y.useEffect(()=>{try{const u={blendMode:r.blendMode||"normal",opacity:r.opacity??1,id:r.id,mask:r.maskSource?{source:r.maskSource,type:r.maskType||"alpha"}:void 0,renderOrder:0};n(a,u)}catch(u){console.error("Error updating metadata:",u)}},[r.blendMode,r.opacity,r.maskSource,r.maskType,r.id,a,n]),r.ref&&typeof r.ref=="function")try{r.ref(null)}catch{}return zr.jsx(oe.Provider,{value:h,children:r.children})},ld={VERTEX:"vertex"},Rn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},jh=["x","y","z","w"],gr="00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff".split(".");let Bv=1234567;const uA=Math.PI/180,hA=180/Math.PI;function Nd(){let r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(gr[r&255]+gr[r>>8&255]+gr[r>>16&255]+gr[r>>24&255]+"-"+gr[t&255]+gr[t>>8&255]+"-"+gr[t>>16&15|64]+gr[t>>24&255]+"-"+gr[e&63|128]+gr[e>>8&255]+"-"+gr[e>>16&255]+gr[e>>24&255]+gr[s&255]+gr[s>>8&255]+gr[s>>16&255]+gr[s>>24&255]).toLowerCase()}function kt(r,t,e){return Math.max(t,Math.min(e,r))}function tx(r,t){return(r%t+t)%t}function Att(r,t,e,s,i){return s+(r-t)*(i-s)/(e-t)}function ztt(r,t,e){return r===t?0:(e-r)/(t-r)}function ku(r,t,e){return(1-e)*r+e*t}function Ctt(r,t,e,s){return ku(r,t,1-Math.exp(-e*s))}function Ett(r,t=1){return t-Math.abs(tx(r,t*2)-t)}function Vtt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Rtt(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Ltt(r,t){return r+Math.floor(Math.random()*(t-r+1))}function Itt(r,t){return r+Math.random()*(t-r)}function Ptt(r){return r*(.5-Math.random())}function Ftt(r){r!==void 0&&(Bv=r);let t=Bv+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Ott(r){return r*uA}function Btt(r){return r*hA}function ktt(r){return(r&r-1)==0&&r!==0}function Dtt(r){return 2**Math.ceil(Math.log(r)/Math.LN2)}function Utt(r){return 2**Math.floor(Math.log(r)/Math.LN2)}function $tt(r,t,e,s,i){let n=Math.cos,a=Math.sin,o=n(e/2),l=a(e/2),h=n((t+s)/2),u=a((t+s)/2),c=n((t-s)/2),d=a((t-s)/2),p=n((s-t)/2),m=a((s-t)/2);switch(i){case"XYX":r.set(o*u,l*c,l*d,o*h);break;case"YZY":r.set(l*d,o*u,l*c,o*h);break;case"ZXZ":r.set(l*c,l*d,o*u,o*h);break;case"XZX":r.set(o*u,l*m,l*p,o*h);break;case"YXY":r.set(l*p,o*u,l*m,o*h);break;case"ZYZ":r.set(l*m,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Gs(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw Error("Invalid component type.")}}function Ht(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw Error("Invalid component type.")}}const jtt={DEG2RAD:uA,RAD2DEG:hA,generateUUID:Nd,clamp:kt,euclideanModulo:tx,mapLinear:Att,inverseLerp:ztt,lerp:ku,damp:Ctt,pingpong:Ett,smoothstep:Vtt,smootherstep:Rtt,randInt:Ltt,randFloat:Itt,randFloatSpread:Ptt,seededRandom:Ftt,degToRad:Ott,radToDeg:Btt,isPowerOfTwo:ktt,ceilPowerOfTwo:Dtt,floorPowerOfTwo:Utt,setQuaternionFromProperEuler:$tt,normalize:Ht,denormalize:Gs},Lg=0,Wtt=1015,Ig="",Us="srgb",kv="srgb-linear",Dv="linear",Du="srgb",op=35044,Ca=2e3,Pg=2001;var Wh=class cA{constructor(t,e,s,i,n,a,o,l,h){cA.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h)}set(t,e,s,i,n,a,o,l,h){let u=this.elements;return u[0]=t,u[1]=i,u[2]=o,u[3]=e,u[4]=n,u[5]=l,u[6]=s,u[7]=a,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[3],l=s[6],h=s[1],u=s[4],c=s[7],d=s[2],p=s[5],m=s[8],f=i[0],x=i[3],b=i[6],w=i[1],S=i[4],_=i[7],V=i[2],z=i[5],A=i[8];return n[0]=a*f+o*w+l*V,n[3]=a*x+o*S+l*z,n[6]=a*b+o*_+l*A,n[1]=h*f+u*w+c*V,n[4]=h*x+u*S+c*z,n[7]=h*b+u*_+c*A,n[2]=d*f+p*w+m*V,n[5]=d*x+p*S+m*z,n[8]=d*b+p*_+m*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8];return e*a*u-e*o*h-s*n*u+s*o*l+i*n*h-i*a*l}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=u*a-o*h,d=o*l-u*n,p=h*n-a*l,m=e*c+s*d+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/m;return t[0]=c*f,t[1]=(i*h-u*s)*f,t[2]=(o*s-i*a)*f,t[3]=d*f,t[4]=(u*e-i*l)*f,t[5]=(i*n-o*e)*f,t[6]=p*f,t[7]=(s*l-h*e)*f,t[8]=(a*e-s*n)*f,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,s,i,n,a,o){let l=Math.cos(n),h=Math.sin(n);return this.set(s*l,s*h,-s*(l*a+h*o)+a+t,-i*h,i*l,-i*(-h*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Of.makeScale(t,e)),this}rotate(t){return this.premultiply(Of.makeRotation(-t)),this}translate(t,e){return this.premultiply(Of.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<9;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new this.constructor().fromArray(this.elements)}};const Of=new Wh,Uv={};function $v(r){r in Uv||(Uv[r]=!0,console.warn(r))}const jv=new Wh().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Wv=new Wh().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function qtt(){let r={enabled:!0,workingColorSpace:kv,spaces:{},convert:function(i,n,a){return this.enabled===!1||n===a||!n||!a||(this.spaces[n].transfer===Du&&(i.r=xl(i.r),i.g=xl(i.g),i.b=xl(i.b)),this.spaces[n].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Du&&(i.r=bl(i.r),i.g=bl(i.g),i.b=bl(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Ig?Dv:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,a){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return $v("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),r.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return $v("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),r.colorSpaceToWorking(i,n)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],s=[.3127,.329];return r.define({[kv]:{primaries:t,whitePoint:s,transfer:Dv,toXYZ:jv,fromXYZ:Wv,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Us},outputColorSpaceConfig:{drawingBufferColorSpace:Us}},[Us]:{primaries:t,whitePoint:s,transfer:Du,toXYZ:jv,fromXYZ:Wv,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Us}}}),r}const Oe=qtt();function xl(r){return r<.04045?r*.0773993808:(r*.9478672986+.0521327014)**2.4}function bl(r){return r<.0031308?r*12.92:1.055*r**.41666-.055}const dA={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},zn={h:0,s:0,l:0},ud={h:0,s:0,l:0};function Bf(r,t,e){return e<0&&(e+=1),e>1&&--e,e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}var ex=class{constructor(r,t,e){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(r,t,e)}set(r,t,e){if(t===void 0&&e===void 0){let s=r;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(r,t,e);return this}setScalar(r){return this.r=r,this.g=r,this.b=r,this}setHex(r,t=Us){return r=Math.floor(r),this.r=(r>>16&255)/255,this.g=(r>>8&255)/255,this.b=(r&255)/255,Oe.colorSpaceToWorking(this,t),this}setRGB(r,t,e,s=Oe.workingColorSpace){return this.r=r,this.g=t,this.b=e,Oe.colorSpaceToWorking(this,s),this}setHSL(r,t,e,s=Oe.workingColorSpace){if(r=tx(r,1),t=kt(t,0,1),e=kt(e,0,1),t===0)this.r=this.g=this.b=e;else{let i=e<=.5?e*(1+t):e+t-e*t,n=2*e-i;this.r=Bf(n,i,r+1/3),this.g=Bf(n,i,r),this.b=Bf(n,i,r-1/3)}return Oe.colorSpaceToWorking(this,s),this}setStyle(r,t=Us){function e(i){i!==void 0&&parseFloat(i)<1&&console.warn("THREE.Color: Alpha component of "+r+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(r)){let i,n=s[1],a=s[2];switch(n){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return e(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+r)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(r)){let i=s[1],n=i.length;if(n===3)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(n===6)return this.setHex(parseInt(i,16),t);console.warn("THREE.Color: Invalid hex color "+r)}else if(r&&r.length>0)return this.setColorName(r,t);return this}setColorName(r,t=Us){let e=dA[r.toLowerCase()];return e===void 0?console.warn("THREE.Color: Unknown color "+r):this.setHex(e,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(r){return this.r=r.r,this.g=r.g,this.b=r.b,this}copySRGBToLinear(r){return this.r=xl(r.r),this.g=xl(r.g),this.b=xl(r.b),this}copyLinearToSRGB(r){return this.r=bl(r.r),this.g=bl(r.g),this.b=bl(r.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(r=Us){return Oe.workingToColorSpace(yr.copy(this),r),Math.round(kt(yr.r*255,0,255))*65536+Math.round(kt(yr.g*255,0,255))*256+Math.round(kt(yr.b*255,0,255))}getHexString(r=Us){return("000000"+this.getHex(r).toString(16)).slice(-6)}getHSL(r,t=Oe.workingColorSpace){Oe.workingToColorSpace(yr.copy(this),t);let e=yr.r,s=yr.g,i=yr.b,n=Math.max(e,s,i),a=Math.min(e,s,i),o,l,h=(a+n)/2;if(a===n)o=0,l=0;else{let u=n-a;switch(l=h<=.5?u/(n+a):u/(2-n-a),n){case e:o=(s-i)/u+(s<i?6:0);break;case s:o=(i-e)/u+2;break;case i:o=(e-s)/u+4;break}o/=6}return r.h=o,r.s=l,r.l=h,r}getRGB(r,t=Oe.workingColorSpace){return Oe.workingToColorSpace(yr.copy(this),t),r.r=yr.r,r.g=yr.g,r.b=yr.b,r}getStyle(r=Us){Oe.workingToColorSpace(yr.copy(this),r);let t=yr.r,e=yr.g,s=yr.b;return r===Us?`rgb(${Math.round(t*255)},${Math.round(e*255)},${Math.round(s*255)})`:`color(${r} ${t.toFixed(3)} ${e.toFixed(3)} ${s.toFixed(3)})`}offsetHSL(r,t,e){return this.getHSL(zn),this.setHSL(zn.h+r,zn.s+t,zn.l+e)}add(r){return this.r+=r.r,this.g+=r.g,this.b+=r.b,this}addColors(r,t){return this.r=r.r+t.r,this.g=r.g+t.g,this.b=r.b+t.b,this}addScalar(r){return this.r+=r,this.g+=r,this.b+=r,this}sub(r){return this.r=Math.max(0,this.r-r.r),this.g=Math.max(0,this.g-r.g),this.b=Math.max(0,this.b-r.b),this}multiply(r){return this.r*=r.r,this.g*=r.g,this.b*=r.b,this}multiplyScalar(r){return this.r*=r,this.g*=r,this.b*=r,this}lerp(r,t){return this.r+=(r.r-this.r)*t,this.g+=(r.g-this.g)*t,this.b+=(r.b-this.b)*t,this}lerpColors(r,t,e){return this.r=r.r+(t.r-r.r)*e,this.g=r.g+(t.g-r.g)*e,this.b=r.b+(t.b-r.b)*e,this}lerpHSL(r,t){this.getHSL(zn),r.getHSL(ud);let e=ku(zn.h,ud.h,t),s=ku(zn.s,ud.s,t),i=ku(zn.l,ud.l,t);return this.setHSL(e,s,i),this}setFromVector3(r){return this.r=r.x,this.g=r.y,this.b=r.z,this}applyMatrix3(r){let t=this.r,e=this.g,s=this.b,i=r.elements;return this.r=i[0]*t+i[3]*e+i[6]*s,this.g=i[1]*t+i[4]*e+i[7]*s,this.b=i[2]*t+i[5]*e+i[8]*s,this}equals(r){return r.r===this.r&&r.g===this.g&&r.b===this.b}fromArray(r,t=0){return this.r=r[t],this.g=r[t+1],this.b=r[t+2],this}toArray(r=[],t=0){return r[t]=this.r,r[t+1]=this.g,r[t+2]=this.b,r}fromBufferAttribute(r,t){return this.r=r.getX(t),this.g=r.getY(t),this.b=r.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const yr=new ex;ex.NAMES=dA;var Htt=class pA{constructor(t,e,s,i){pA.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let s=0;s<4;s++)this.elements[s]=t[s+e];return this}set(t,e,s,i){let n=this.elements;return n[0]=t,n[2]=e,n[1]=s,n[3]=i,this}},Gtt=class{constructor(r=0,t=0,e=0,s=1){this.isQuaternion=!0,this._x=r,this._y=t,this._z=e,this._w=s}static slerpFlat(r,t,e,s,i,n,a){let o=e[s+0],l=e[s+1],h=e[s+2],u=e[s+3],c=i[n+0],d=i[n+1],p=i[n+2],m=i[n+3];if(a===0){r[t+0]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u;return}if(a===1){r[t+0]=c,r[t+1]=d,r[t+2]=p,r[t+3]=m;return}if(u!==m||o!==c||l!==d||h!==p){let f=1-a,x=o*c+l*d+h*p+u*m,b=x>=0?1:-1,w=1-x*x;if(w>2**-52){let _=Math.sqrt(w),V=Math.atan2(_,x*b);f=Math.sin(f*V)/_,a=Math.sin(a*V)/_}let S=a*b;if(o=o*f+c*S,l=l*f+d*S,h=h*f+p*S,u=u*f+m*S,f===1-a){let _=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=_,l*=_,h*=_,u*=_}}r[t]=o,r[t+1]=l,r[t+2]=h,r[t+3]=u}static multiplyQuaternionsFlat(r,t,e,s,i,n){let a=e[s],o=e[s+1],l=e[s+2],h=e[s+3],u=i[n],c=i[n+1],d=i[n+2],p=i[n+3];return r[t]=a*p+h*u+o*d-l*c,r[t+1]=o*p+h*c+l*u-a*d,r[t+2]=l*p+h*d+a*c-o*u,r[t+3]=h*p-a*u-o*c-l*d,r}get x(){return this._x}set x(r){this._x=r,this._onChangeCallback()}get y(){return this._y}set y(r){this._y=r,this._onChangeCallback()}get z(){return this._z}set z(r){this._z=r,this._onChangeCallback()}get w(){return this._w}set w(r){this._w=r,this._onChangeCallback()}set(r,t,e,s){return this._x=r,this._y=t,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(r){return this._x=r.x,this._y=r.y,this._z=r.z,this._w=r.w,this._onChangeCallback(),this}setFromEuler(r,t=!0){let e=r._x,s=r._y,i=r._z,n=r._order,a=Math.cos,o=Math.sin,l=a(e/2),h=a(s/2),u=a(i/2),c=o(e/2),d=o(s/2),p=o(i/2);switch(n){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(r,t){let e=t/2,s=Math.sin(e);return this._x=r.x*s,this._y=r.y*s,this._z=r.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(r){let t=r.elements,e=t[0],s=t[4],i=t[8],n=t[1],a=t[5],o=t[9],l=t[2],h=t[6],u=t[10],c=e+a+u;if(c>0){let d=.5/Math.sqrt(c+1);this._w=.25/d,this._x=(h-o)*d,this._y=(i-l)*d,this._z=(n-s)*d}else if(e>a&&e>u){let d=2*Math.sqrt(1+e-a-u);this._w=(h-o)/d,this._x=.25*d,this._y=(s+n)/d,this._z=(i+l)/d}else if(a>u){let d=2*Math.sqrt(1+a-e-u);this._w=(i-l)/d,this._x=(s+n)/d,this._y=.25*d,this._z=(o+h)/d}else{let d=2*Math.sqrt(1+u-e-a);this._w=(n-s)/d,this._x=(i+l)/d,this._y=(o+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(r,t){let e=r.dot(t)+1;return e<2**-52?(e=0,Math.abs(r.x)>Math.abs(r.z)?(this._x=-r.y,this._y=r.x,this._z=0,this._w=e):(this._x=0,this._y=-r.z,this._z=r.y,this._w=e)):(this._x=r.y*t.z-r.z*t.y,this._y=r.z*t.x-r.x*t.z,this._z=r.x*t.y-r.y*t.x,this._w=e),this.normalize()}angleTo(r){return 2*Math.acos(Math.abs(kt(this.dot(r),-1,1)))}rotateTowards(r,t){let e=this.angleTo(r);if(e===0)return this;let s=Math.min(1,t/e);return this.slerp(r,s),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(r){return this._x*r._x+this._y*r._y+this._z*r._z+this._w*r._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 r=this.length();return r===0?(this._x=0,this._y=0,this._z=0,this._w=1):(r=1/r,this._x*=r,this._y*=r,this._z*=r,this._w*=r),this._onChangeCallback(),this}multiply(r){return this.multiplyQuaternions(this,r)}premultiply(r){return this.multiplyQuaternions(r,this)}multiplyQuaternions(r,t){let e=r._x,s=r._y,i=r._z,n=r._w,a=t._x,o=t._y,l=t._z,h=t._w;return this._x=e*h+n*a+s*l-i*o,this._y=s*h+n*o+i*a-e*l,this._z=i*h+n*l+e*o-s*a,this._w=n*h-e*a-s*o-i*l,this._onChangeCallback(),this}slerp(r,t){if(t===0)return this;if(t===1)return this.copy(r);let e=this._x,s=this._y,i=this._z,n=this._w,a=n*r._w+e*r._x+s*r._y+i*r._z;if(a<0?(this._w=-r._w,this._x=-r._x,this._y=-r._y,this._z=-r._z,a=-a):this.copy(r),a>=1)return this._w=n,this._x=e,this._y=s,this._z=i,this;let o=1-a*a;if(o<=2**-52){let d=1-t;return this._w=d*n+t*this._w,this._x=d*e+t*this._x,this._y=d*s+t*this._y,this._z=d*i+t*this._z,this.normalize(),this}let l=Math.sqrt(o),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,c=Math.sin(t*h)/l;return this._w=n*u+this._w*c,this._x=e*u+this._x*c,this._y=s*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(r,t,e){return this.copy(r).slerp(t,e)}random(){let r=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(r),s*Math.cos(r),i*Math.sin(t),i*Math.cos(t))}equals(r){return r._x===this._x&&r._y===this._y&&r._z===this._z&&r._w===this._w}fromArray(r,t=0){return this._x=r[t],this._y=r[t+1],this._z=r[t+2],this._w=r[t+3],this._onChangeCallback(),this}toArray(r=[],t=0){return r[t]=this._x,r[t+1]=this._y,r[t+2]=this._z,r[t+3]=this._w,r}fromBufferAttribute(r,t){return this._x=r.getX(t),this._y=r.getY(t),this._z=r.getZ(t),this._w=r.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(r){return this._onChangeCallback=r,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ti=class mA{constructor(t=0,e=0,s=0){mA.prototype.isVector3=!0,this.x=t,this.y=e,this.z=s}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(qv.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qv.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6]*i,this.y=n[1]*e+n[4]*s+n[7]*i,this.z=n[2]*e+n[5]*s+n[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=t.elements,a=1/(n[3]*e+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*s+n[8]*i+n[12])*a,this.y=(n[1]*e+n[5]*s+n[9]*i+n[13])*a,this.z=(n[2]*e+n[6]*s+n[10]*i+n[14])*a,this}applyQuaternion(t){let e=this.x,s=this.y,i=this.z,n=t.x,a=t.y,o=t.z,l=t.w,h=2*(a*i-o*s),u=2*(o*e-n*i),c=2*(n*s-a*e);return this.x=e+l*h+a*c-o*u,this.y=s+l*u+o*h-n*c,this.z=i+l*c+n*u-a*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,s=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*s+n[8]*i,this.y=n[1]*e+n[5]*s+n[9]*i,this.z=n[2]*e+n[6]*s+n[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let s=t.x,i=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-n*o,this.y=n*a-s*l,this.z=s*o-i*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return kf.copy(this).projectOnVector(t),this.sub(kf)}reflect(t){return this.sub(kf.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(kt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y,i=this.z-t.z;return e*e+s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,s){let i=Math.sin(e)*t;return this.x=i*Math.sin(s),this.y=Math.cos(e)*t,this.z=i*Math.cos(s),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,s){return this.x=t*Math.sin(e),this.y=s,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const kf=new ti,qv=new Gtt;var fA=class Fg{constructor(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){Fg.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x)}set(t,e,s,i,n,a,o,l,h,u,c,d,p,m,f,x){let b=this.elements;return b[0]=t,b[4]=e,b[8]=s,b[12]=i,b[1]=n,b[5]=a,b[9]=o,b[13]=l,b[2]=h,b[6]=u,b[10]=c,b[14]=d,b[3]=p,b[7]=m,b[11]=f,b[15]=x,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 Fg().fromArray(this.elements)}copy(t){let e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){let e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,s=t.elements,i=1/Wo.setFromMatrixColumn(t,0).length(),n=1/Wo.setFromMatrixColumn(t,1).length(),a=1/Wo.setFromMatrixColumn(t,2).length();return e[0]=s[0]*i,e[1]=s[1]*i,e[2]=s[2]*i,e[3]=0,e[4]=s[4]*n,e[5]=s[5]*n,e[6]=s[6]*n,e[7]=0,e[8]=s[8]*a,e[9]=s[9]*a,e[10]=s[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,s=t.x,i=t.y,n=t.z,a=Math.cos(s),o=Math.sin(s),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),c=Math.sin(n);if(t.order==="XYZ"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=-l*c,e[8]=h,e[1]=p+m*h,e[5]=d-f*h,e[9]=-o*l,e[2]=f-d*h,e[6]=m+p*h,e[10]=a*l}else if(t.order==="YXZ"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d+f*o,e[4]=m*o-p,e[8]=a*h,e[1]=a*c,e[5]=a*u,e[9]=-o,e[2]=p*o-m,e[6]=f+d*o,e[10]=a*l}else if(t.order==="ZXY"){let d=l*u,p=l*c,m=h*u,f=h*c;e[0]=d-f*o,e[4]=-a*c,e[8]=m+p*o,e[1]=p+m*o,e[5]=a*u,e[9]=f-d*o,e[2]=-a*h,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){let d=a*u,p=a*c,m=o*u,f=o*c;e[0]=l*u,e[4]=m*h-p,e[8]=d*h+f,e[1]=l*c,e[5]=f*h+d,e[9]=p*h-m,e[2]=-h,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=f-d*c,e[8]=m*c+p,e[1]=c,e[5]=a*u,e[9]=-o*u,e[2]=-h*u,e[6]=p*c+m,e[10]=d-f*c}else if(t.order==="XZY"){let d=a*l,p=a*h,m=o*l,f=o*h;e[0]=l*u,e[4]=-c,e[8]=h*u,e[1]=d*c+f,e[5]=a*u,e[9]=p*c-m,e[2]=m*c-p,e[6]=o*u,e[10]=f*c+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Xtt,t,Ytt)}lookAt(t,e,s){let i=this.elements;return Wr.subVectors(t,e),Wr.lengthSq()===0&&(Wr.z=1),Wr.normalize(),Cn.crossVectors(s,Wr),Cn.lengthSq()===0&&(Math.abs(s.z)===1?Wr.x+=1e-4:Wr.z+=1e-4,Wr.normalize(),Cn.crossVectors(s,Wr)),Cn.normalize(),hd.crossVectors(Wr,Cn),i[0]=Cn.x,i[4]=hd.x,i[8]=Wr.x,i[1]=Cn.y,i[5]=hd.y,i[9]=Wr.y,i[2]=Cn.z,i[6]=hd.z,i[10]=Wr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let s=t.elements,i=e.elements,n=this.elements,a=s[0],o=s[4],l=s[8],h=s[12],u=s[1],c=s[5],d=s[9],p=s[13],m=s[2],f=s[6],x=s[10],b=s[14],w=s[3],S=s[7],_=s[11],V=s[15],z=i[0],A=i[4],I=i[8],et=i[12],nt=i[1],it=i[5],vt=i[9],mt=i[13],Rt=i[2],Vt=i[6],Yt=i[10],se=i[14],te=i[3],ft=i[7],bt=i[11],Et=i[15];return n[0]=a*z+o*nt+l*Rt+h*te,n[4]=a*A+o*it+l*Vt+h*ft,n[8]=a*I+o*vt+l*Yt+h*bt,n[12]=a*et+o*mt+l*se+h*Et,n[1]=u*z+c*nt+d*Rt+p*te,n[5]=u*A+c*it+d*Vt+p*ft,n[9]=u*I+c*vt+d*Yt+p*bt,n[13]=u*et+c*mt+d*se+p*Et,n[2]=m*z+f*nt+x*Rt+b*te,n[6]=m*A+f*it+x*Vt+b*ft,n[10]=m*I+f*vt+x*Yt+b*bt,n[14]=m*et+f*mt+x*se+b*Et,n[3]=w*z+S*nt+_*Rt+V*te,n[7]=w*A+S*it+_*Vt+V*ft,n[11]=w*I+S*vt+_*Yt+V*bt,n[15]=w*et+S*mt+_*se+V*Et,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],s=t[4],i=t[8],n=t[12],a=t[1],o=t[5],l=t[9],h=t[13],u=t[2],c=t[6],d=t[10],p=t[14],m=t[3],f=t[7],x=t[11],b=t[15];return m*(+n*l*c-i*h*c-n*o*d+s*h*d+i*o*p-s*l*p)+f*(+e*l*p-e*h*d+n*a*d-i*a*p+i*h*u-n*l*u)+x*(+e*h*c-e*o*p-n*a*c+s*a*p+n*o*u-s*h*u)+b*(-i*o*u-e*l*c+e*o*d+i*a*c-s*a*d+s*l*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=s),this}invert(){let t=this.elements,e=t[0],s=t[1],i=t[2],n=t[3],a=t[4],o=t[5],l=t[6],h=t[7],u=t[8],c=t[9],d=t[10],p=t[11],m=t[12],f=t[13],x=t[14],b=t[15],w=c*x*h-f*d*h+f*l*p-o*x*p-c*l*b+o*d*b,S=m*d*h-u*x*h-m*l*p+a*x*p+u*l*b-a*d*b,_=u*f*h-m*c*h+m*o*p-a*f*p-u*o*b+a*c*b,V=m*c*l-u*f*l-m*o*d+a*f*d+u*o*x-a*c*x,z=e*w+s*S+i*_+n*V;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/z;return t[0]=w*A,t[1]=(f*d*n-c*x*n-f*i*p+s*x*p+c*i*b-s*d*b)*A,t[2]=(o*x*n-f*l*n+f*i*h-s*x*h-o*i*b+s*l*b)*A,t[3]=(c*l*n-o*d*n-c*i*h+s*d*h+o*i*p-s*l*p)*A,t[4]=S*A,t[5]=(u*x*n-m*d*n+m*i*p-e*x*p-u*i*b+e*d*b)*A,t[6]=(m*l*n-a*x*n-m*i*h+e*x*h+a*i*b-e*l*b)*A,t[7]=(a*d*n-u*l*n+u*i*h-e*d*h-a*i*p+e*l*p)*A,t[8]=_*A,t[9]=(m*c*n-u*f*n-m*s*p+e*f*p+u*s*b-e*c*b)*A,t[10]=(a*f*n-m*o*n+m*s*h-e*f*h-a*s*b+e*o*b)*A,t[11]=(u*o*n-a*c*n-u*s*h+e*c*h+a*s*p-e*o*p)*A,t[12]=V*A,t[13]=(u*f*i-m*c*i+m*s*d-e*f*d-u*s*x+e*c*x)*A,t[14]=(m*o*i-a*f*i-m*s*l+e*f*l+a*s*x-e*o*x)*A,t[15]=(a*c*i-u*o*i+u*s*l-e*c*l-a*s*d+e*o*d)*A,this}scale(t){let e=this.elements,s=t.x,i=t.y,n=t.z;return e[0]*=s,e[4]*=i,e[8]*=n,e[1]*=s,e[5]*=i,e[9]*=n,e[2]*=s,e[6]*=i,e[10]*=n,e[3]*=s,e[7]*=i,e[11]*=n,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,i))}makeTranslation(t,e,s){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let s=Math.cos(e),i=Math.sin(e),n=1-s,a=t.x,o=t.y,l=t.z,h=n*a,u=n*o;return this.set(h*a+s,h*o-i*l,h*l+i*o,0,h*o+i*l,u*o+s,u*l-i*a,0,h*l-i*o,u*l+i*a,n*l*l+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,i,n,a){return this.set(1,s,n,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,s){let i=this.elements,n=e._x,a=e._y,o=e._z,l=e._w,h=n+n,u=a+a,c=o+o,d=n*h,p=n*u,m=n*c,f=a*u,x=a*c,b=o*c,w=l*h,S=l*u,_=l*c,V=s.x,z=s.y,A=s.z;return i[0]=(1-(f+b))*V,i[1]=(p+_)*V,i[2]=(m-S)*V,i[3]=0,i[4]=(p-_)*z,i[5]=(1-(d+b))*z,i[6]=(x+w)*z,i[7]=0,i[8]=(m+S)*A,i[9]=(x-w)*A,i[10]=(1-(d+f))*A,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,s){let i=this.elements,n=Wo.set(i[0],i[1],i[2]).length(),a=Wo.set(i[4],i[5],i[6]).length(),o=Wo.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],Ps.copy(this);let h=1/n,u=1/a,c=1/o;return Ps.elements[0]*=h,Ps.elements[1]*=h,Ps.elements[2]*=h,Ps.elements[4]*=u,Ps.elements[5]*=u,Ps.elements[6]*=u,Ps.elements[8]*=c,Ps.elements[9]*=c,Ps.elements[10]*=c,e.setFromRotationMatrix(Ps),s.x=n,s.y=a,s.z=o,this}makePerspective(t,e,s,i,n,a,o=Ca){let l=this.elements,h=2*n/(e-t),u=2*n/(s-i),c=(e+t)/(e-t),d=(s+i)/(s-i),p,m;if(o===Ca)p=-(a+n)/(a-n),m=-2*a*n/(a-n);else if(o===Pg)p=-a/(a-n),m=-a*n/(a-n);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=c,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,s,i,n,a,o=Ca){let l=this.elements,h=1/(e-t),u=1/(s-i),c=1/(a-n),d=(e+t)*h,p=(s+i)*u,m,f;if(o===Ca)m=(a+n)*c,f=-2*c;else if(o===Pg)m=n*c,f=-1*c;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*h,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=f,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,s=t.elements;for(let i=0;i<16;i++)if(e[i]!==s[i])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){let s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};const Wo=new ti,Ps=new fA,Xtt=new ti(0,0,0),Ytt=new ti(1,1,1),Cn=new ti,hd=new ti,Wr=new ti;var gA=class yA{constructor(t=0,e=0){yA.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,s=this.y,i=t.elements;return this.x=i[0]*e+i[3]*s+i[6],this.y=i[1]*e+i[4]*s+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let s=this.dot(t)/e;return Math.acos(kt(s,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let s=Math.cos(e),i=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*s-a*i+t.x,this.y=n*i+a*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ztt=class xA{constructor(t=0,e=0,s=0,i=1){xA.prototype.isVector4=!0,this.x=t,this.y=e,this.z=s,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,s,i){return this.x=t,this.y=e,this.z=s,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w===void 0?1:t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,s=this.y,i=this.z,n=this.w,a=t.elements;return this.x=a[0]*e+a[4]*s+a[8]*i+a[12]*n,this.y=a[1]*e+a[5]*s+a[9]*i+a[13]*n,this.z=a[2]*e+a[6]*s+a[10]*i+a[14]*n,this.w=a[3]*e+a[7]*s+a[11]*i+a[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,s,i,n,a=.01,o=.1,l=t.elements,h=l[0],u=l[4],c=l[8],d=l[1],p=l[5],m=l[9],f=l[2],x=l[6],b=l[10];if(Math.abs(u-d)<a&&Math.abs(c-f)<a&&Math.abs(m-x)<a){if(Math.abs(u+d)<o&&Math.abs(c+f)<o&&Math.abs(m+x)<o&&Math.abs(h+p+b-3)<o)return this.set(1,0,0,0),this;e=Math.PI;let S=(h+1)/2,_=(p+1)/2,V=(b+1)/2,z=(u+d)/4,A=(c+f)/4,I=(m+x)/4;return S>_&&S>V?S<a?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(S),i=z/s,n=A/s):_>V?_<a?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(_),s=z/i,n=I/i):V<a?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(V),s=A/n,i=I/n),this.set(s,i,n,e),this}let w=Math.sqrt((x-m)*(x-m)+(c-f)*(c-f)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(x-m)/w,this.y=(c-f)/w,this.z=(d-u)/w,this.w=Math.acos((h+p+b-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=kt(this.x,t.x,e.x),this.y=kt(this.y,t.y,e.y),this.z=kt(this.z,t.z,e.z),this.w=kt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=kt(this.x,t,e),this.y=kt(this.y,t,e),this.z=kt(this.z,t,e),this.w=kt(this.w,t,e),this}clampLength(t,e){let s=this.length();return this.divideScalar(s||1).multiplyScalar(kt(s,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this.w=t.w+(e.w-t.w)*s,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function Og(r,t=0){let e=3735928559^t,s=1103547991^t;if(r instanceof Array)for(let i=0,n;i<r.length;i++)n=r[i],e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<r.length;i++)n=r.charCodeAt(i),e=Math.imul(e^n,2654435761),s=Math.imul(s^n,1597334677);return e=Math.imul(e^e>>>16,2246822507),e^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(e^e>>>13,3266489909),4294967296*(2097151&s)+(e>>>0)}const bA=(...r)=>Og(r);function Jtt(r,t=!1){let e=[];r.isNode===!0&&(e.push(r.id),r=r.getSelf());for(let{property:s,childNode:i}of Bg(r))e.push(Og(s.slice(0,-4)),i.getCacheKey(t));return Og(e)}function*Bg(r,t=!1){for(let e in r){if(e.startsWith("_")===!0)continue;let s=r[e];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:e,childNode:s};else if(typeof s=="object")for(let i in s){let n=s[i];n&&(n.isNode===!0||t&&typeof n.toJSON=="function")&&(yield{property:e,index:i,childNode:n})}}}function kg(r){if(r==null)return null;let t=typeof r;return r.isNode===!0?"node":t==="number"?"float":t==="boolean"?"bool":t==="string"?"string":t==="function"?"shader":r.isVector2===!0?"vec2":r.isVector3===!0?"vec3":r.isVector4===!0?"vec4":r.isMatrix2===!0?"mat2":r.isMatrix3===!0?"mat3":r.isMatrix4===!0?"mat4":r.isColor===!0?"color":r instanceof ArrayBuffer?"ArrayBuffer":null}function vA(r,...t){let e=r?r.slice(-4):void 0;return t.length===1&&(e==="vec2"?t=[t[0],t[0]]:e==="vec3"?t=[t[0],t[0],t[0]]:e==="vec4"&&(t=[t[0],t[0],t[0],t[0]])),r==="color"?new ex(...t):e==="vec2"?new gA(...t):e==="vec3"?new ti(...t):e==="vec4"?new Ztt(...t):e==="mat2"?new Htt(...t):e==="mat3"?new Wh(...t):e==="mat4"?new fA(...t):r==="bool"?t[0]||!1:r==="float"||r==="int"||r==="uint"?t[0]||0:r==="string"?t[0]||"":r==="ArrayBuffer"?Ktt(t[0]):null}function Qtt(r){let t="",e=new Uint8Array(r);for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return btoa(t)}function Ktt(r){return Uint8Array.from(atob(r),t=>t.charCodeAt(0)).buffer}var tet=class{addEventListener(r,t){this._listeners===void 0&&(this._listeners={});let e=this._listeners;e[r]===void 0&&(e[r]=[]),e[r].indexOf(t)===-1&&e[r].push(t)}hasEventListener(r,t){let e=this._listeners;return e===void 0?!1:e[r]!==void 0&&e[r].indexOf(t)!==-1}removeEventListener(r,t){let e=this._listeners;if(e===void 0)return;let s=e[r];if(s!==void 0){let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}dispatchEvent(r){let t=this._listeners;if(t===void 0)return;let e=t[r.type];if(e!==void 0){r.target=this;let s=e.slice(0);for(let i=0,n=s.length;i<n;i++)s[i].call(this,r);r.target=null}}};const eet={analyze:"setup",generate:"analyze"};let ret=0;var set=class extends tet{static get type(){return"Node"}constructor(r=null){super(),this.nodeType=r,this.updateType=Rn.NONE,this.updateBeforeType=Rn.NONE,this.updateAfterType=Rn.NONE,this.uuid=jtt.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:ret++})}set needsUpdate(r){r===!0&&this.version++}get type(){return this.constructor.type}onUpdate(r,t){return this.updateType=t,this.update=r.bind(this.getSelf()),this}onFrameUpdate(r){return this.onUpdate(r,Rn.FRAME)}onRenderUpdate(r){return this.onUpdate(r,Rn.RENDER)}onObjectUpdate(r){return this.onUpdate(r,Rn.OBJECT)}onReference(r){return this.updateReference=r.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:r}of Bg(this))yield r}dispose(){this.dispatchEvent({type:"dispose"})}traverse(r){r(this);for(let t of this.getChildren())t.traverse(r)}getCacheKey(r=!1){return r||(r=this.version!==this._cacheKeyVersion),(r===!0||this._cacheKey===null)&&(this._cacheKey=bA(Jtt(this,r),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(r){let t=this.getNodeType(r);return r.getElementType(t)}getMemberType(){return"void"}getNodeType(r){let t=r.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(r):this.nodeType}getShared(r){let t=this.getHash(r);return r.getNodeFromHash(t)||this}setup(r){let t=r.getNodeProperties(this),e=0;for(let s of this.getChildren())t["node"+e++]=s;return t.outputNode||null}analyze(r,t=null){let e=r.increaseUsage(this);if(this.parents===!0){let s=r.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[r.shaderStage]=s.stages[r.shaderStage]||[],s.stages[r.shaderStage].push(t)}if(e===1){let s=r.getNodeProperties(this);for(let i of Object.values(s))i&&i.isNode===!0&&i.build(r,this)}}generate(r,t){let{outputNode:e}=r.getNodeProperties(this);if(e&&e.isNode===!0)return e.build(r,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(r,t=null){let e=this.getShared(r);if(this!==e)return e.build(r,t);let s=r.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[r.buildStage]=!0;let i=eet[r.buildStage];if(i&&s.buildStages[i]!==!0){let o=r.getBuildStage();r.setBuildStage(i),this.build(r),r.setBuildStage(o)}r.addNode(this),r.addChain(this);let n=null,a=r.getBuildStage();if(a==="setup"){this.updateReference(r);let o=r.getNodeProperties(this);if(o.initialized!==!0){o.initialized=!0,o.outputNode=this.setup(r)||o.outputNode||null;for(let l of Object.values(o))if(l&&l.isNode===!0){if(l.parents===!0){let h=r.getNodeProperties(l);h.parents=h.parents||[],h.parents.push(this)}l.build(r)}}n=o.outputNode}else if(a==="analyze")this.analyze(r,t);else if(a==="generate")if(this.generate.length===1){let l=this.getNodeType(r),h=r.getDataFromNode(this);n=h.snippet,n===void 0?h.generated===void 0?(h.generated=!0,n=this.generate(r)||"",h.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n=""):h.flowCodes!==void 0&&r.context.nodeBlock!==void 0&&r.addFlowCodeHierarchy(this,r.context.nodeBlock),n=r.format(n,l,t)}else n=this.generate(r,t)||"";return r.removeChain(this),r.addSequentialNode(this),n}getSerializeChildren(){return Bg(this)}serialize(r){let t=this.getSerializeChildren(),e={};for(let{property:s,index:i,childNode:n}of t)i===void 0?e[s]=n.toJSON(r.meta).uuid:(e[s]===void 0&&(e[s]=Number.isInteger(i)?[]:{}),e[s][i]=n.toJSON(r.meta).uuid);Object.keys(e).length>0&&(r.inputNodes=e)}deserialize(r){if(r.inputNodes!==void 0){let t=r.meta.nodes;for(let e in r.inputNodes)if(Array.isArray(r.inputNodes[e])){let s=[];for(let i of r.inputNodes[e])s.push(t[i]);this[e]=s}else if(typeof r.inputNodes[e]=="object"){let s={};for(let i in r.inputNodes[e]){let n=r.inputNodes[e][i];s[i]=t[n]}this[e]=s}else{let s=r.inputNodes[e];this[e]=t[s]}}}toJSON(r){let{uuid:t,type:e}=this,s=r===void 0||typeof r=="string";s&&(r={textures:{},images:{},nodes:{}});let i=r.nodes[t];i===void 0&&(i={uuid:t,type:e,meta:r,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(r.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function n(a){let o=[];for(let l in a){let h=a[l];delete h.metadata,o.push(h)}return o}if(s){let a=n(r.textures),o=n(r.images),l=n(r.nodes);a.length>0&&(i.textures=a),o.length>0&&(i.images=o),l.length>0&&(i.nodes=l)}return i}},$e=set,iet=class extends $e{static get type(){return"TempNode"}constructor(r=null){super(r),this.isTempNode=!0}hasDependencies(r){return r.getDataFromNode(this).usageCount>1}build(r,t){if(r.getBuildStage()==="generate"){let s=r.getVectorType(this.getNodeType(r,t)),i=r.getDataFromNode(this);if(i.propertyName!==void 0)return r.format(i.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(r)){let n=super.build(r,s),a=r.getVarFromNode(this,null,s),o=r.getPropertyName(a);return r.addLineFlowCode(`${o} = ${n}`,this),i.snippet=n,i.propertyName=o,r.format(i.propertyName,s,t)}}return super.build(r,t)}},is=iet,net=class extends $e{static get type(){return"ArrayElementNode"}constructor(r,t){super(),this.node=r,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(r){return this.node.getElementType(r)}generate(r){let t=this.indexNode.getNodeType(r),e=this.node.build(r),s=this.indexNode.build(r,!r.isVector(t)&&r.isInteger(t)?t:"uint");return`${e}[ ${s} ]`}},rx=net,aet=class extends $e{static get type(){return"ConvertNode"}constructor(r,t){super(),this.node=r,this.convertTo=t}getNodeType(r){let t=this.node.getNodeType(r),e=null;for(let s of this.convertTo.split("|"))(e===null||r.getTypeLength(t)===r.getTypeLength(s))&&(e=s);return e}serialize(r){super.serialize(r),r.convertTo=this.convertTo}deserialize(r){super.deserialize(r),this.convertTo=r.convertTo}generate(r,t){let e=this.node,s=this.getNodeType(r),i=e.build(r,s);return r.format(i,s,t)}},wA=aet,oet=class extends is{static get type(){return"JoinNode"}constructor(r=[],t=null){super(t),this.nodes=r}getNodeType(r){return this.nodeType===null?r.getTypeFromLength(this.nodes.reduce((t,e)=>t+r.getTypeLength(e.getNodeType(r)),0)):r.getVectorType(this.nodeType)}generate(r,t){let e=this.getNodeType(r),s=r.getTypeLength(e),i=this.nodes,n=r.getComponentType(e),a=[],o=0;for(let h of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${e}()' type.`);break}let u=h.getNodeType(r),c=r.getTypeLength(u),d;o+c>s&&(console.error(`THREE.TSL: Length of '${e}()' data exceeds maximum length of output type.`),c=s-o,u=r.getTypeFromLength(c)),o+=c,d=h.build(r,u);let p=r.getComponentType(u);p!==n&&(d=r.format(d,p,n)),a.push(d)}let l=`${r.getType(e)}( ${a.join(", ")} )`;return r.format(l,e,t)}},uet=oet;const het=jh.join("");var cet=class extends $e{static get type(){return"SplitNode"}constructor(r,t="x"){super(),this.node=r,this.components=t,this.isSplitNode=!0}getVectorLength(){let r=this.components.length;for(let t of this.components)r=Math.max(jh.indexOf(t)+1,r);return r}getComponentType(r){return r.getComponentType(this.node.getNodeType(r))}getNodeType(r){return r.getTypeFromLength(this.components.length,this.getComponentType(r))}generate(r,t){let e=this.node,s=r.getTypeLength(e.getNodeType(r)),i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=r.getTypeFromLength(this.getVectorLength(),this.getComponentType(r)));let o=e.build(r,n);i=this.components.length===s&&this.components===het.slice(0,this.components.length)?r.format(o,n,t):r.format(`${o}.${this.components}`,this.getNodeType(r),t)}else i=e.build(r,t);return i}serialize(r){super.serialize(r),r.components=this.components}deserialize(r){super.deserialize(r),this.components=r.components}},Hv=cet,det=class extends is{static get type(){return"SetNode"}constructor(r,t,e){super(),this.sourceNode=r,this.components=t,this.targetNode=e}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{sourceNode:t,components:e,targetNode:s}=this,i=this.getNodeType(r),n=r.getComponentType(s.getNodeType(r)),a=r.getTypeFromLength(e.length,n),o=s.build(r,a),l=t.build(r,i),h=r.getTypeLength(i),u=[];for(let c=0;c<h;c++){let d=jh[c];d===e[0]?(u.push(o),c+=e.length-1):u.push(l+"."+d)}return`${r.getType(i)}( ${u.join(", ")} )`}},pet=det,met=class extends is{static get type(){return"FlipNode"}constructor(r,t){super(),this.sourceNode=r,this.components=t}getNodeType(r){return this.sourceNode.getNodeType(r)}generate(r){let{components:t,sourceNode:e}=this,s=this.getNodeType(r),i=e.build(r),n=r.getVarFromNode(this),a=r.getPropertyName(n);r.addLineFlowCode(a+" = "+i,this);let o=r.getTypeLength(s),l=[],h=0;for(let u=0;u<o;u++){let c=jh[u];c===t[h]?(l.push("1.0 - "+(a+"."+c)),h++):l.push(a+"."+c)}return`${r.getType(s)}( ${l.join(", ")} )`}},fet=met,get=class extends $e{static get type(){return"InputNode"}constructor(r,t=null){super(t),this.isInputNode=!0,this.value=r,this.precision=null}getNodeType(){return this.nodeType===null?kg(this.value):this.nodeType}getInputType(r){return this.getNodeType(r)}setPrecision(r){return this.precision=r,this}serialize(r){super.serialize(r),r.value=this.value,this.value&&this.value.toArray&&(r.value=this.value.toArray()),r.valueType=kg(this.value),r.nodeType=this.nodeType,r.valueType==="ArrayBuffer"&&(r.value=Qtt(r.value)),r.precision=this.precision}deserialize(r){super.deserialize(r),this.nodeType=r.nodeType,this.value=Array.isArray(r.value)?vA(r.valueType,...r.value):r.value,this.precision=r.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(r.value))}generate(){console.warn("Abstract function.")}},sx=get;const Gv=/float|u?int/;var yet=class extends sx{static get type(){return"ConstNode"}constructor(r,t=null){super(r,t),this.isConstNode=!0}generateConst(r){return r.generateConst(this.getNodeType(r),this.value)}generate(r,t){let e=this.getNodeType(r);return Gv.test(e)&&Gv.test(t)?r.generateConst(t,this.value):r.format(this.generateConst(r),e,t)}},mn=yet,xet=class extends $e{static get type(){return"MemberNode"}constructor(r,t){super(),this.node=r,this.property=t,this.isMemberNode=!0}getNodeType(r){return this.node.getMemberType(r,this.property)}generate(r){return this.node.build(r)+"."+this.property}},bet=xet;let vet=null;const rl=new Map;function j(r,t){if(rl.has(r)){console.warn(`THREE.TSL: Redefinition of method chaining '${r}'.`);return}if(typeof t!="function")throw Error(`THREE.TSL: Node element ${r} is not a function`);rl.set(r,t)}const MA=r=>r.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Xv=r=>MA(r).split("").sort().join(""),TA={setup(r,t){let e=t.shift();return r(Jp(e),...t)},get(r,t,e){if(typeof t=="string"&&r[t]===void 0){if(r.isStackNode!==!0&&t==="assign")return(...s)=>(vet.assign(e,...s),e);if(rl.has(t)){let s=rl.get(t);return r.isStackNode?(...i)=>e.add(s(...i)):(...i)=>s(e,...i)}else{if(t==="self")return r;if(t.endsWith("Assign")&&rl.has(t.slice(0,t.length-6))){let s=rl.get(t.slice(0,t.length-6));return r.isStackNode?(...i)=>e.assign(i[0],s(...i)):(...i)=>e.assign(s(e,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=MA(t),ht(new Hv(e,t));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Xv(t.slice(3).toLowerCase()),s=>ht(new pet(r,t,ht(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=Xv(t.slice(4).toLowerCase()),()=>ht(new fet(ht(r),t));if(t==="width"||t==="height"||t==="depth")return t==="width"?t="x":t==="height"?t="y":t==="depth"&&(t="z"),ht(new Hv(r,t));if(/^\d+$/.test(t)===!0)return ht(new rx(e,new mn(Number(t),"uint")));if(/^get$/.test(t)===!0)return s=>ht(new bet(e,s))}}}return Reflect.get(r,t,e)},set(r,t,e,s){return typeof t=="string"&&r[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t==="width"||t==="height"||t==="depth"||/^\d+$/.test(t)===!0)?(s[t].assign(e),!0):Reflect.set(r,t,e,s)}},Df=new WeakMap,Yv=new WeakMap,wet=function(r,t=null){let e=kg(r);if(e==="node"){let s=Df.get(r);return s===void 0&&(s=new Proxy(r,TA),Df.set(r,s),Df.set(s,s)),s}else{if(t===null&&(e==="float"||e==="boolean")||e&&e!=="shader"&&e!=="string")return ht(Dg(r,t));if(e==="shader")return As(r)}return r},Met=function(r,t=null){for(let e in r)r[e]=ht(r[e],t);return r},Tet=function(r,t=null){let e=r.length;for(let s=0;s<e;s++)r[s]=ht(r[s],t);return r},Net=function(r,t=null,e=null,s=null){let i=u=>ht(s===null?u:Object.assign(u,s)),n,a=t,o,l;function h(u){let c;return c=a?/[a-z]/i.test(a)?a+"()":a:r.type,o!==void 0&&u.length<o?(console.error(`THREE.TSL: "${c}" parameter length is less than minimum required.`),u.concat(Array(o-u.length).fill(0))):l!==void 0&&u.length>l?(console.error(`THREE.TSL: "${c}" parameter length exceeds limit.`),u.slice(0,l)):u}return t===null?n=(...u)=>i(new r(...Sd(h(u)))):e===null?n=(...u)=>i(new r(t,...Sd(h(u)))):(e=ht(e),n=(...u)=>i(new r(t,...Sd(h(u)),e))),n.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),n),n.setName=u=>(a=u,n),n};var _et=class extends $e{constructor(r,t){super(),this.shaderNode=r,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(r){return this.shaderNode.nodeType||this.getOutputNode(r).getNodeType(r)}getMemberType(r,t){return this.getOutputNode(r).getMemberType(r,t)}call(r){let{shaderNode:t,inputNodes:e}=this,s=r.getNodeProperties(t),i=t.namespace&&t.namespace===r.namespace?r.getNamespace("once"):"once";if(s[i])return s[i];let n=null;if(t.layout){let a=Yv.get(r.constructor);a===void 0&&(a=new WeakMap,Yv.set(r.constructor,a));let o=a.get(t);o===void 0&&(o=ht(r.buildFunctionNode(t)),a.set(t,o)),r.addInclude(o),n=ht(o.call(e))}else{let a=t.jsFunc,o=e!==null||a.length>1?a(e||[],r):a(r);n=ht(o)}return t.once&&(s[i]=n),n}setupOutput(r){return r.addStack(),r.stack.outputNode=this.call(r),r.removeStack()}getOutputNode(r){let t=r.getNodeProperties(this),e=r.getOutputNamespace();return t[e]=t[e]||this.setupOutput(r),t[e]}build(r,t=null){let e=null,s=r.getBuildStage(),i=r.getNodeProperties(this),n=r.getOutputNamespace(),a=this.getOutputNode(r);if(s==="setup"){let o=r.getNamespace("initialized");i[o]!==!0&&(i[o]=!0,i[n]=this.getOutputNode(r),i[n].build(r)),e=i[n]}else s==="analyze"?a.build(r,t):s==="generate"&&(e=a.build(r,t)||"");return e}},Aet=class extends $e{constructor(r,t){super(t),this.jsFunc=r,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(r){return this.layout=r,this}call(r=null){return Jp(r),ht(new _et(this,r))}setup(){return this.call()}};const zet=[!1,!0],Cet=[0,1,2,3],Eet=[-1,-2],NA=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],ix=new Map;for(let r of zet)ix.set(r,new mn(r));const nx=new Map;for(let r of Cet)nx.set(r,new mn(r,"uint"));const ax=new Map([...nx].map(r=>new mn(r.value,"int")));for(let r of Eet)ax.set(r,new mn(r,"int"));const Yp=new Map([...ax].map(r=>new mn(r.value)));for(let r of NA)Yp.set(r,new mn(r));for(let r of NA)Yp.set(-r,new mn(-r));const Zp={bool:ix,uint:nx,ints:ax,float:Yp},Zv=new Map([...ix,...Yp]),Dg=(r,t)=>Zv.has(r)?Zv.get(r):r.isNode===!0?r:new mn(r,t),Vet=r=>{try{return r.getNodeType()}catch{return}},je=function(r,t=null){return(...e)=>{if((e.length===0||!["bool","float","int","uint"].includes(r)&&e.every(i=>typeof i!="object"))&&(e=[vA(r,...e)]),e.length===1&&t!==null&&t.has(e[0]))return ht(t.get(e[0]));if(e.length===1){let i=Dg(e[0],r);return Vet(i)===r?ht(i):ht(new wA(i,r))}let s=e.map(i=>Dg(i));return ht(new uet(s,r))}},Ret=r=>r==null?null:r.nodeType||r.convertTo||(typeof r=="string"?r:null);function Let(r,t){return new Proxy(new Aet(r,t),TA)}const ht=(r,t=null)=>wet(r,t),Jp=(r,t=null)=>new Met(r,t),Sd=(r,t=null)=>new Tet(r,t),tt=(...r)=>new Net(...r);let Iet=0;const As=(r,t=null)=>{let e=null;t!==null&&(typeof t=="object"?e=t.return:(typeof t=="string"?e=t:console.error("THREE.TSL: Invalid layout type."),t=null));let s=new Let(r,e),i=(...n)=>{let a;Jp(n),a=n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?[...n]:n[0];let l=s.call(a);return e==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),t!==null){if(typeof t.inputs!="object"){let n={name:"fn"+Iet++,type:e,inputs:[]};for(let a in t)a!=="return"&&n.inputs.push({name:a,type:t[a]});t=n}i.setLayout(t)}return i};function Pet(r){return r}j("toStack",Pet);const Fet=new je("color"),Mi=new je("float",Zp.float),ih=new je("int",Zp.ints),Oet=new je("uint",Zp.uint),Bet=new je("bool",Zp.bool),SA=new je("vec2"),ket=new je("ivec2"),Det=new je("uvec2"),Uet=new je("bvec2"),Ol=new je("vec3"),$et=new je("ivec3"),jet=new je("uvec3"),Wet=new je("bvec3"),ka=new je("vec4"),qet=new je("ivec4"),Het=new je("uvec4"),Get=new je("bvec4"),Xet=new je("mat2"),_A=new je("mat3"),Yet=new je("mat4");j("toColor",Fet),j("toFloat",Mi),j("toInt",ih),j("toUint",Oet),j("toBool",Bet),j("toVec2",SA),j("toIVec2",ket),j("toUVec2",Det),j("toBVec2",Uet),j("toVec3",Ol),j("toIVec3",$et),j("toUVec3",jet),j("toBVec3",Wet),j("toVec4",ka),j("toIVec4",qet),j("toUVec4",Het),j("toBVec4",Get),j("toMat2",Xet),j("toMat3",_A),j("toMat4",Yet);const Zet=tt(rx).setParameterLength(2),Jet=(r,t)=>ht(new wA(ht(r),t));j("element",Zet),j("convert",Jet),j("append",r=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),r));const Qet={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};var Le=class Ug extends is{static get type(){return"OperatorNode"}constructor(t,e,s,...i){if(super(),i.length>0){let n=new Ug(t,e,s);for(let a=0;a<i.length-1;a++)n=new Ug(t,n,i[a]);e=n,s=i[i.length-1]}this.op=t,this.aNode=e,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(t,e){return t.getMethod(Qet[this.op],e)}getNodeType(t){let e=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(t),a=i?i.getNodeType(t):null;if(n==="void"||a==="void")return"void";if(e==="%")return n;if(e==="~"||e==="&"||e==="|"||e==="^"||e===">>"||e==="<<")return t.getIntegerType(n);if(e==="!"||e==="&&"||e==="||"||e==="^^")return"bool";if(e==="=="||e==="!="||e==="<"||e===">"||e==="<="||e===">="){let o=Math.max(t.getTypeLength(n),t.getTypeLength(a));return o>1?`bvec${o}`:"bool"}else{if(t.isMatrix(n)){if(a==="float")return n;if(t.isVector(a))return t.getVectorFromMatrix(n);if(t.isMatrix(a))return n}else if(t.isMatrix(a)){if(n==="float")return a;if(t.isVector(n))return t.getVectorFromMatrix(a)}return t.getTypeLength(a)>t.getTypeLength(n)?a:n}}generate(t,e){let s=this.op,{aNode:i,bNode:n}=this,a=this.getNodeType(t),o=null,l=null;a==="void"?o=l=a:(o=i.getNodeType(t),l=n?n.getNodeType(t):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?t.isVector(o)?l=o:t.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=a,l=t.changeComponentType(l,"uint")):s==="%"?(o=a,l=t.isInteger(o)&&t.isInteger(l)?l:o):t.isMatrix(o)?l==="float"?l="float":t.isVector(l)?l=t.getVectorFromMatrix(o):t.isMatrix(l)||(o=l=a):o=t.isMatrix(l)?o==="float"?"float":t.isVector(o)?t.getVectorFromMatrix(l):l=a:l=a);let h=i.build(t,o),u=n?n.build(t,l):null,c=t.getFunctionOperator(s);if(e!=="void"){let d=t.renderer.coordinateSystem===Ca;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d&&t.isVector(o)?t.format(`${this.getOperatorMethod(t,e)}( ${h}, ${u} )`,a,e):t.format(`( ${h} ${s} ${u} )`,a,e);if(s==="%")return t.isInteger(l)?t.format(`( ${h} % ${u} )`,a,e):t.format(`${this.getOperatorMethod(t,a)}( ${h}, ${u} )`,a,e);if(s==="!"||s==="~")return t.format(`(${s}${h})`,o,e);if(c)return t.format(`${c}( ${h}, ${u} )`,a,e);if(t.isMatrix(o)&&l==="float")return t.format(`( ${u} ${s} ${h} )`,a,e);if(o==="float"&&t.isMatrix(l))return t.format(`${h} ${s} ${u}`,a,e);{let p=`( ${h} ${s} ${u} )`;return!d&&a==="bool"&&t.isVector(o)&&t.isVector(l)&&(p=`all${p}`),t.format(p,a,e)}}else if(o!=="void")return c?t.format(`${c}( ${h}, ${u} )`,a,e):t.isMatrix(o)&&l==="float"?t.format(`${u} ${s} ${h}`,a,e):t.format(`${h} ${s} ${u}`,a,e)}serialize(t){super.serialize(t),t.op=this.op}deserialize(t){super.deserialize(t),this.op=t.op}};const AA=tt(Le,"+").setParameterLength(2,1/0).setName("add"),$g=tt(Le,"-").setParameterLength(2,1/0).setName("sub"),ox=tt(Le,"*").setParameterLength(2,1/0).setName("mul"),zA=tt(Le,"/").setParameterLength(2,1/0).setName("div"),Qp=tt(Le,"%").setParameterLength(2).setName("mod"),CA=tt(Le,"==").setParameterLength(2).setName("equal"),Ket=tt(Le,"!=").setParameterLength(2).setName("notEqual"),trt=tt(Le,"<").setParameterLength(2).setName("lessThan"),ert=tt(Le,">").setParameterLength(2).setName("greaterThan"),rrt=tt(Le,"<=").setParameterLength(2).setName("lessThanEqual"),srt=tt(Le,">=").setParameterLength(2).setName("greaterThanEqual"),irt=tt(Le,"&&").setParameterLength(2,1/0).setName("and"),nrt=tt(Le,"||").setParameterLength(2,1/0).setName("or"),art=tt(Le,"!").setParameterLength(1).setName("not"),ort=tt(Le,"^^").setParameterLength(2).setName("xor"),lrt=tt(Le,"&").setParameterLength(2).setName("bitAnd"),urt=tt(Le,"~").setParameterLength(2).setName("bitNot"),hrt=tt(Le,"|").setParameterLength(2).setName("bitOr"),crt=tt(Le,"^").setParameterLength(2).setName("bitXor"),drt=tt(Le,"<<").setParameterLength(2).setName("shiftLeft"),prt=tt(Le,">>").setParameterLength(2).setName("shiftRight"),mrt=As(([r])=>(r.addAssign(1),r)),frt=As(([r])=>(r.subAssign(1),r)),grt=As(([r])=>{let t=ih(r).toConst();return r.addAssign(1),t}),yrt=As(([r])=>{let t=ih(r).toConst();return r.subAssign(1),t});j("add",AA),j("sub",$g),j("mul",ox),j("div",zA),j("mod",Qp),j("equal",CA),j("notEqual",Ket),j("lessThan",trt),j("greaterThan",ert),j("lessThanEqual",rrt),j("greaterThanEqual",srt),j("and",irt),j("or",nrt),j("not",art),j("xor",ort),j("bitAnd",lrt),j("bitNot",urt),j("bitOr",hrt),j("bitXor",crt),j("shiftLeft",drt),j("shiftRight",prt),j("incrementBefore",mrt),j("decrementBefore",frt),j("increment",grt),j("decrement",yrt);const xrt=(r,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),Qp(r,t)),brt=(r,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),Qp(ih(r),ih(t)));j("remainder",xrt),j("modInt",brt);var O=class re extends is{static get type(){return"MathNode"}constructor(t,e,s=null,i=null){if(super(),(t===re.MAX||t===re.MIN)&&arguments.length>3){let n=new re(t,e,s);for(let a=2;a<arguments.length-1;a++)n=new re(t,n,arguments[a]);e=n,s=arguments[arguments.length-1],i=null}this.method=t,this.aNode=e,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(t){let e=this.aNode.getNodeType(t),s=this.bNode?this.bNode.getNodeType(t):null,i=this.cNode?this.cNode.getNodeType(t):null,n=t.isMatrix(e)?0:t.getTypeLength(e),a=t.isMatrix(s)?0:t.getTypeLength(s),o=t.isMatrix(i)?0:t.getTypeLength(i);return n>a&&n>o?e:a>o?s:o>n?i:e}getNodeType(t){let e=this.method;return e===re.LENGTH||e===re.DISTANCE||e===re.DOT?"float":e===re.CROSS?"vec3":e===re.ALL||e===re.ANY?"bool":e===re.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),"bool"):this.getInputType(t)}setup(t){let{aNode:e,bNode:s,method:i}=this,n=null;if(i===re.ONE_MINUS)n=$g(1,e);else if(i===re.RECIPROCAL)n=zA(1,e);else if(i===re.DIFFERENCE)n=lx($g(e,s));else if(i===re.TRANSFORM_DIRECTION){let a=e,o=s;t.isMatrix(a.getNodeType(t))?o=ka(Ol(o),0):a=ka(Ol(a),0);let l=ox(a,o).xyz;n=EA(l)}return n===null?super.setup(t):n}generate(t,e){if(t.getNodeProperties(this).outputNode)return super.generate(t,e);let i=this.method,n=this.getNodeType(t),a=this.getInputType(t),o=this.aNode,l=this.bNode,h=this.cNode,u=t.renderer.coordinateSystem;if(i===re.NEGATE)return t.format("( - "+o.build(t,a)+" )",n,e);{let c=[];return i===re.CROSS?c.push(o.build(t,n),l.build(t,n)):u===Ca&&i===re.STEP?c.push(o.build(t,t.getTypeLength(o.getNodeType(t))===1?"float":a),l.build(t,a)):u===Ca&&(i===re.MIN||i===re.MAX)?c.push(o.build(t,a),l.build(t,t.getTypeLength(l.getNodeType(t))===1?"float":a)):i===re.REFRACT?c.push(o.build(t,a),l.build(t,a),h.build(t,"float")):i===re.MIX?c.push(o.build(t,a),l.build(t,a),h.build(t,t.getTypeLength(h.getNodeType(t))===1?"float":a)):(u===Pg&&i===re.ATAN&&l!==null&&(i="atan2"),t.shaderStage!=="fragment"&&(i===re.DFDX||i===re.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i="/*"+i+"*/"),c.push(o.build(t,a)),l!==null&&c.push(l.build(t,a)),h!==null&&c.push(h.build(t,a))),t.format(`${t.getMethod(i,n)}( ${c.join(", ")} )`,n,e)}}serialize(t){super.serialize(t),t.method=this.method}deserialize(t){super.deserialize(t),this.method=t.method}};O.ALL="all",O.ANY="any",O.RADIANS="radians",O.DEGREES="degrees",O.EXP="exp",O.EXP2="exp2",O.LOG="log",O.LOG2="log2",O.SQRT="sqrt",O.INVERSE_SQRT="inversesqrt",O.FLOOR="floor",O.CEIL="ceil",O.NORMALIZE="normalize",O.FRACT="fract",O.SIN="sin",O.COS="cos",O.TAN="tan",O.ASIN="asin",O.ACOS="acos",O.ATAN="atan",O.ABS="abs",O.SIGN="sign",O.LENGTH="length",O.NEGATE="negate",O.ONE_MINUS="oneMinus",O.DFDX="dFdx",O.DFDY="dFdy",O.ROUND="round",O.RECIPROCAL="reciprocal",O.TRUNC="trunc",O.FWIDTH="fwidth",O.TRANSPOSE="transpose",O.BITCAST="bitcast",O.EQUALS="equals",O.MIN="min",O.MAX="max",O.STEP="step",O.REFLECT="reflect",O.DISTANCE="distance",O.DIFFERENCE="difference",O.DOT="dot",O.CROSS="cross",O.POW="pow",O.TRANSFORM_DIRECTION="transformDirection",O.MIX="mix",O.CLAMP="clamp",O.REFRACT="refract",O.SMOOTHSTEP="smoothstep",O.FACEFORWARD="faceforward";const vrt=Mi(Math.PI);Mi(Math.PI*2);const wrt=tt(O,O.ALL).setParameterLength(1),Mrt=tt(O,O.ANY).setParameterLength(1),Trt=tt(O,O.RADIANS).setParameterLength(1),Nrt=tt(O,O.DEGREES).setParameterLength(1),Srt=tt(O,O.EXP).setParameterLength(1),_rt=tt(O,O.EXP2).setParameterLength(1),Art=tt(O,O.LOG).setParameterLength(1),zrt=tt(O,O.LOG2).setParameterLength(1),Crt=tt(O,O.SQRT).setParameterLength(1),Ert=tt(O,O.INVERSE_SQRT).setParameterLength(1),Vrt=tt(O,O.FLOOR).setParameterLength(1),Rrt=tt(O,O.CEIL).setParameterLength(1),EA=tt(O,O.NORMALIZE).setParameterLength(1),VA=tt(O,O.FRACT).setParameterLength(1),RA=tt(O,O.SIN).setParameterLength(1),Lrt=tt(O,O.COS).setParameterLength(1),Irt=tt(O,O.TAN).setParameterLength(1),Prt=tt(O,O.ASIN).setParameterLength(1),Frt=tt(O,O.ACOS).setParameterLength(1),LA=tt(O,O.ATAN).setParameterLength(1,2),lx=tt(O,O.ABS).setParameterLength(1),IA=tt(O,O.SIGN).setParameterLength(1),Ort=tt(O,O.LENGTH).setParameterLength(1),Brt=tt(O,O.NEGATE).setParameterLength(1),krt=tt(O,O.ONE_MINUS).setParameterLength(1),Drt=tt(O,O.DFDX).setParameterLength(1),Urt=tt(O,O.DFDY).setParameterLength(1),$rt=tt(O,O.ROUND).setParameterLength(1),jrt=tt(O,O.RECIPROCAL).setParameterLength(1),Wrt=tt(O,O.TRUNC).setParameterLength(1),qrt=tt(O,O.FWIDTH).setParameterLength(1),Hrt=tt(O,O.TRANSPOSE).setParameterLength(1),Grt=(r,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),CA(r,t)),Xrt=tt(O,O.MIN).setParameterLength(2,1/0),Yrt=tt(O,O.MAX).setParameterLength(2,1/0),Zrt=tt(O,O.STEP).setParameterLength(2),Jrt=tt(O,O.REFLECT).setParameterLength(2),Qrt=tt(O,O.DISTANCE).setParameterLength(2),Krt=tt(O,O.DIFFERENCE).setParameterLength(2),qh=tt(O,O.DOT).setParameterLength(2),tst=tt(O,O.CROSS).setParameterLength(2),PA=tt(O,O.POW).setParameterLength(2),est=tt(O,O.POW,2).setParameterLength(1),rst=tt(O,O.POW,3).setParameterLength(1),sst=tt(O,O.POW,4).setParameterLength(1),ist=tt(O,O.TRANSFORM_DIRECTION).setParameterLength(2),nst=r=>ox(IA(r),PA(lx(r),1/3)),ast=r=>qh(r,r),Kp=tt(O,O.MIX).setParameterLength(3),FA=(r,t=0,e=1)=>ht(new O(O.CLAMP,ht(r),ht(t),ht(e))),ost=r=>FA(r),lst=tt(O,O.REFRACT).setParameterLength(3),ust=tt(O,O.SMOOTHSTEP).setParameterLength(3),hst=tt(O,O.FACEFORWARD).setParameterLength(3),cst=As(([r])=>{let t=12.9898,e=78.233,s=43758.5453,i=qh(r.xy,SA(t,e)),n=Qp(i,vrt);return VA(RA(n).mul(s))}),dst=(r,t,e)=>Kp(t,e,r),pst=(r,t,e)=>ust(t,e,r),mst=(r,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),LA(r,t));j("all",wrt),j("any",Mrt),j("equals",Grt),j("radians",Trt),j("degrees",Nrt),j("exp",Srt),j("exp2",_rt),j("log",Art),j("log2",zrt),j("sqrt",Crt),j("inverseSqrt",Ert),j("floor",Vrt),j("ceil",Rrt),j("normalize",EA),j("fract",VA),j("sin",RA),j("cos",Lrt),j("tan",Irt),j("asin",Prt),j("acos",Frt),j("atan",LA),j("abs",lx),j("sign",IA),j("length",Ort),j("lengthSq",ast),j("negate",Brt),j("oneMinus",krt),j("dFdx",Drt),j("dFdy",Urt),j("round",$rt),j("reciprocal",jrt),j("trunc",Wrt),j("fwidth",qrt),j("atan2",mst),j("min",Xrt),j("max",Yrt),j("step",Zrt),j("reflect",Jrt),j("distance",Qrt),j("dot",qh),j("cross",tst),j("pow",PA),j("pow2",est),j("pow3",rst),j("pow4",sst),j("transformDirection",ist),j("mix",dst),j("clamp",FA),j("refract",lst),j("smoothstep",pst),j("faceForward",hst),j("difference",Krt),j("saturate",ost),j("cbrt",nst),j("transpose",Hrt),j("rand",cst);var Jv=class extends is{static get type(){return"ArrayNode"}constructor(r,t,e=null){super(r),this.count=t,this.values=e,this.isArrayNode=!0}getNodeType(r){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(r)),this.nodeType}getElementType(r){return this.getNodeType(r)}generate(r){let t=this.getNodeType(r);return r.generateArray(t,this.count,this.values)}};const fst=(...r)=>{let t;if(r.length===1){let e=r[0];t=new Jv(null,e.length,e)}else{let e=r[0],s=r[1];t=new Jv(e,s)}return ht(t)};j("toArray",(r,t)=>fst(Array(t).fill(r)));var OA=class extends $e{static get type(){return"UniformGroupNode"}constructor(r,t=!1,e=1){super("string"),this.name=r,this.shared=t,this.order=e,this.isUniformGroup=!0}serialize(r){super.serialize(r),r.name=this.name,r.version=this.version,r.shared=this.shared}deserialize(r){super.deserialize(r),this.name=r.name,this.version=r.version,this.shared=r.shared}};const gst=r=>new OA(r),yst=(r,t=0)=>new OA(r,!0,t),xst=yst("render"),bst=gst("object");var vst=class extends sx{static get type(){return"UniformNode"}constructor(r,t=null){super(r,t),this.isUniformNode=!0,this.name="",this.groupNode=bst}label(r){return this.name=r,this}setGroup(r){return this.groupNode=r,this}getGroup(){return this.groupNode}getUniformHash(r){return this.getHash(r)}onUpdate(r,t){let e=this.getSelf();return r=r.bind(e),super.onUpdate(s=>{let i=r(s,e);i!==void 0&&(this.value=i)},t)}generate(r,t){let e=this.getNodeType(r),s=this.getUniformHash(r),i=r.getNodeFromHash(s);i===void 0&&(r.setHashNode(this,s),i=this);let n=i.getInputType(r),a=r.getUniformFromNode(i,n,r.shaderStage,this.name||r.context.label),o=r.getPropertyName(a);return r.context.label!==void 0&&delete r.context.label,r.format(o,e,t)}};const wst=(r,t)=>{let e=Ret(t||r),s=r;return ht(new vst(s,e))};var Mst=class extends $e{static get type(){return"PropertyNode"}constructor(r,t=null,e=!1){super(r),this.name=t,this.varying=e,this.isPropertyNode=!0,this.global=!0}getHash(r){return this.name||super.getHash(r)}generate(r){let t;return this.varying===!0?(t=r.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=r.getVarFromNode(this,this.name),r.getPropertyName(t)}};const Tst=(r,t)=>ht(new Mst(r,t));var Nst=class extends is{static get type(){return"AssignNode"}constructor(r,t){super(),this.targetNode=r,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(r,t){return t==="void"?"void":this.targetNode.getNodeType(r)}needsSplitAssign(r){let{targetNode:t}=this;if(r.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){let e=r.getTypeLength(t.node.getNodeType(r));return jh.join("").slice(0,e)!==t.components}return!1}setup(r){let{targetNode:t,sourceNode:e}=this,s=r.getNodeProperties(this);s.sourceNode=e,s.targetNode=t.context({assign:!0})}generate(r,t){let{targetNode:e,sourceNode:s}=r.getNodeProperties(this),i=this.needsSplitAssign(r),n=e.getNodeType(r),a=e.build(r),o=s.build(r,n),l=s.getNodeType(r),h=r.getDataFromNode(this),u;if(h.initialized===!0)t!=="void"&&(u=a);else if(i){let c=r.getVarFromNode(this,null,n),d=r.getPropertyName(c);r.addLineFlowCode(`${d} = ${o}`,this);let p=e.node,m=p.node.context({assign:!0}),f=m.build(r);for(let x=0;x<p.components.length;x++){let b=p.components[x];r.addLineFlowCode(`${f}.${b} = ${d}[ ${x} ]`,this)}t!=="void"&&(u=a)}else u=`${a} = ${o}`,(t==="void"||l==="void")&&(r.addLineFlowCode(u,this),t!=="void"&&(u=a));return h.initialized=!0,r.format(u,n,t)}};const Sst=tt(Nst).setParameterLength(2);j("assign",Sst);var _st=class extends is{static get type(){return"FunctionCallNode"}constructor(r=null,t={}){super(),this.functionNode=r,this.parameters=t}setParameters(r){return this.parameters=r,this}getParameters(){return this.parameters}getNodeType(r){return this.functionNode.getNodeType(r)}generate(r){let t=[],e=this.functionNode,s=e.getInputs(r),i=this.parameters,n=(o,l)=>{let h=l.type,u=h==="pointer",c;return c=u?"&"+o.build(r):o.build(r,h),c};if(Array.isArray(i)){if(i.length>s.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),i.length=s.length;else if(i.length<s.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<s.length;)i.push(Mi(0));for(let o=0;o<i.length;o++)t.push(n(i[o],s[o]))}else for(let o of s){let l=i[o.name];l===void 0?(console.error(`THREE.TSL: Input '${o.name}' not found in 'Fn()'.`),t.push(n(Mi(0),o))):t.push(n(l,o))}return`${e.build(r,"property")}( ${t.join(", ")} )`}};const Ast=(r,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?Sd(t):Jp(t[0]),ht(new _st(ht(r),t)));j("call",Ast);var zst=class extends $e{static get type(){return"ConditionalNode"}constructor(r,t,e=null){super(),this.condNode=r,this.ifNode=t,this.elseNode=e}getNodeType(r){let{ifNode:t,elseNode:e}=r.getNodeProperties(this);if(t===void 0)return this.setup(r),this.getNodeType(r);let s=t.getNodeType(r);if(e!==null){let i=e.getNodeType(r);if(r.getTypeLength(i)>r.getTypeLength(s))return i}return s}setup(r){let t=this.condNode.cache(),e=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=r.context.nodeBlock;r.getDataFromNode(e).parentNodeBlock=i,s!==null&&(r.getDataFromNode(s).parentNodeBlock=i);let n=r.getNodeProperties(this);n.condNode=t,n.ifNode=e.context({nodeBlock:e}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(r,t){let e=this.getNodeType(r),s=r.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;let{condNode:i,ifNode:n,elseNode:a}=r.getNodeProperties(this),o=r.currentFunctionNode,l=t!=="void",h=l?Tst(e).build(r):"";s.nodeProperty=h;let u=i.build(r,"bool");r.addFlowCode(`
|
|
151
151
|
${r.tab}if ( ${u} ) {
|
|
152
152
|
|
|
153
153
|
`).addFlowTab();let c=n.build(r,e);if(c&&(l?c=h+" = "+c+";":(c="return "+c+";",o===null&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),c="// "+c))),r.removeFlowTab().addFlowCode(r.tab+" "+c+`
|