super-three
Version:
JavaScript 3D library
6 lines • 567 kB
JavaScript
/**
* @license
* Copyright 2010-2025 Three.js Authors
* SPDX-License-Identifier: MIT
*/
import{Color as e,Vector2 as t,Vector3 as r,Vector4 as s,Matrix2 as i,Matrix3 as n,Matrix4 as a,EventDispatcher as o,MathUtils as u,WebGLCoordinateSystem as l,WebGPUCoordinateSystem as d,ColorManagement as c,SRGBTransfer as h,NoToneMapping as p,StaticDrawUsage as g,InterleavedBuffer as m,DynamicDrawUsage as f,InterleavedBufferAttribute as y,NoColorSpace as b,UnsignedIntType as x,IntType as T,NearestFilter as _,Texture as v,Sphere as N,BackSide as S,DoubleSide as E,Euler as w,CubeReflectionMapping as A,CubeRefractionMapping as R,CubeTexture as C,TangentSpaceNormalMap as M,ObjectSpaceNormalMap as P,InstancedInterleavedBuffer as B,InstancedBufferAttribute as L,DataArrayTexture as F,FloatType as I,FramebufferTexture as D,LinearMipmapLinearFilter as V,DepthTexture as U,Material as O,NormalBlending as k,LineBasicMaterial as G,LineDashedMaterial as z,NoBlending as H,SRGBColorSpace as $,MeshNormalMaterial as W,WebGLCubeRenderTarget as q,BoxGeometry as j,Mesh as X,Scene as K,LinearFilter as Y,CubeCamera as Q,EquirectangularReflectionMapping as Z,EquirectangularRefractionMapping as J,AddOperation as ee,MixOperation as te,MultiplyOperation as re,MeshBasicMaterial as se,MeshLambertMaterial as ie,MeshPhongMaterial as ne,BufferGeometry as ae,BufferAttribute as oe,RenderTarget as ue,CubeUVReflectionMapping as le,OrthographicCamera as de,HalfFloatType as ce,RGBAFormat as he,LinearSRGBColorSpace as pe,PerspectiveCamera as ge,MeshStandardMaterial as me,MeshPhysicalMaterial as fe,MeshToonMaterial as ye,MeshMatcapMaterial as be,SpriteMaterial as xe,PointsMaterial as Te,ShadowMaterial as _e,arrayNeedsUint32 as ve,Uint32BufferAttribute as Ne,Uint16BufferAttribute as Se,Camera as Ee,DepthStencilFormat as we,DepthFormat as Ae,UnsignedInt248Type as Re,UnsignedByteType as Ce,Plane as Me,Object3D as Pe,LinearMipMapLinearFilter as Be,Float32BufferAttribute as Le,UVMapping as Fe,VSMShadowMap as Ie,LessCompare as De,RGFormat as Ve,BasicShadowMap as Ue,SphereGeometry as Oe,LinearMipmapNearestFilter as ke,NearestMipmapLinearFilter as Ge,Float16BufferAttribute as ze,REVISION as He,ArrayCamera as $e,PlaneGeometry as We,FrontSide as qe,CustomBlending as je,AddEquation as Xe,ZeroFactor as Ke,CylinderGeometry as Ye,WebXRController as Qe,RAD2DEG as Ze,Quaternion as Je,PCFShadowMap as et,Frustum as tt,FrustumArray as rt,DataTexture as st,RedIntegerFormat as it,RedFormat as nt,RGIntegerFormat as at,RGBIntegerFormat as ot,RGBFormat as ut,RGBAIntegerFormat as lt,UnsignedShortType as dt,ByteType as ct,ShortType as ht,warnOnce as pt,createCanvasElement as gt,SubtractEquation as mt,ReverseSubtractEquation as ft,OneFactor as yt,SrcColorFactor as bt,SrcAlphaFactor as xt,SrcAlphaSaturateFactor as Tt,DstColorFactor as _t,DstAlphaFactor as vt,OneMinusSrcColorFactor as Nt,OneMinusSrcAlphaFactor as St,OneMinusDstColorFactor as Et,OneMinusDstAlphaFactor as wt,CullFaceNone as At,CullFaceBack as Rt,CullFaceFront as Ct,MultiplyBlending as Mt,SubtractiveBlending as Pt,AdditiveBlending as Bt,NotEqualDepth as Lt,GreaterDepth as Ft,GreaterEqualDepth as It,EqualDepth as Dt,LessEqualDepth as Vt,LessDepth as Ut,AlwaysDepth as Ot,NeverDepth as kt,UnsignedShort4444Type as Gt,UnsignedShort5551Type as zt,UnsignedInt5999Type as Ht,AlphaFormat as $t,RGB_S3TC_DXT1_Format as Wt,RGBA_S3TC_DXT1_Format as qt,RGBA_S3TC_DXT3_Format as jt,RGBA_S3TC_DXT5_Format as Xt,RGB_PVRTC_4BPPV1_Format as Kt,RGB_PVRTC_2BPPV1_Format as Yt,RGBA_PVRTC_4BPPV1_Format as Qt,RGBA_PVRTC_2BPPV1_Format as Zt,RGB_ETC1_Format as Jt,RGB_ETC2_Format as er,RGBA_ETC2_EAC_Format as tr,RGBA_ASTC_4x4_Format as rr,RGBA_ASTC_5x4_Format as sr,RGBA_ASTC_5x5_Format as ir,RGBA_ASTC_6x5_Format as nr,RGBA_ASTC_6x6_Format as ar,RGBA_ASTC_8x5_Format as or,RGBA_ASTC_8x6_Format as ur,RGBA_ASTC_8x8_Format as lr,RGBA_ASTC_10x5_Format as dr,RGBA_ASTC_10x6_Format as cr,RGBA_ASTC_10x8_Format as hr,RGBA_ASTC_10x10_Format as pr,RGBA_ASTC_12x10_Format as gr,RGBA_ASTC_12x12_Format as mr,RGBA_BPTC_Format as fr,RED_RGTC1_Format as yr,SIGNED_RED_RGTC1_Format as br,RED_GREEN_RGTC2_Format as xr,SIGNED_RED_GREEN_RGTC2_Format as Tr,RepeatWrapping as _r,ClampToEdgeWrapping as vr,MirroredRepeatWrapping as Nr,NearestMipmapNearestFilter as Sr,NeverCompare as Er,AlwaysCompare as wr,LessEqualCompare as Ar,EqualCompare as Rr,GreaterEqualCompare as Cr,GreaterCompare as Mr,NotEqualCompare as Pr,LinearTransfer as Br,NotEqualStencilFunc as Lr,GreaterStencilFunc as Fr,GreaterEqualStencilFunc as Ir,EqualStencilFunc as Dr,LessEqualStencilFunc as Vr,LessStencilFunc as Ur,AlwaysStencilFunc as Or,NeverStencilFunc as kr,DecrementWrapStencilOp as Gr,IncrementWrapStencilOp as zr,DecrementStencilOp as Hr,IncrementStencilOp as $r,InvertStencilOp as Wr,ReplaceStencilOp as qr,ZeroStencilOp as jr,KeepStencilOp as Xr,MaxEquation as Kr,MinEquation as Yr,SpotLight as Qr,PointLight as Zr,DirectionalLight as Jr,RectAreaLight as es,AmbientLight as ts,HemisphereLight as rs,LightProbe as ss,LinearToneMapping as is,ReinhardToneMapping as ns,CineonToneMapping as as,ACESFilmicToneMapping as os,AgXToneMapping as us,NeutralToneMapping as ls,Group as ds,Loader as cs,FileLoader as hs,MaterialLoader as ps,ObjectLoader as gs}from"./three.core.min.js";export{AdditiveAnimationBlendMode,AnimationAction,AnimationClip,AnimationLoader,AnimationMixer,AnimationObjectGroup,AnimationUtils,ArcCurve,ArrowHelper,AttachedBindMode,Audio,AudioAnalyser,AudioContext,AudioListener,AudioLoader,AxesHelper,BasicDepthPacking,BatchedMesh,Bone,BooleanKeyframeTrack,Box2,Box3,Box3Helper,BoxHelper,BufferGeometryLoader,Cache,CameraHelper,CanvasTexture,CapsuleGeometry,CatmullRomCurve3,CircleGeometry,Clock,ColorKeyframeTrack,CompressedArrayTexture,CompressedCubeTexture,CompressedTexture,CompressedTextureLoader,ConeGeometry,ConstantAlphaFactor,ConstantColorFactor,Controls,CubeTextureLoader,CubicBezierCurve,CubicBezierCurve3,CubicInterpolant,CullFaceFrontBack,Curve,CurvePath,CustomToneMapping,Cylindrical,Data3DTexture,DataTextureLoader,DataUtils,DefaultLoadingManager,DetachedBindMode,DirectionalLightHelper,DiscreteInterpolant,DodecahedronGeometry,DynamicCopyUsage,DynamicReadUsage,EdgesGeometry,EllipseCurve,ExtrudeGeometry,Fog,FogExp2,GLBufferAttribute,GLSL1,GLSL3,GridHelper,HemisphereLightHelper,IcosahedronGeometry,ImageBitmapLoader,ImageLoader,ImageUtils,InstancedBufferGeometry,InstancedMesh,Int16BufferAttribute,Int32BufferAttribute,Int8BufferAttribute,Interpolant,InterpolateDiscrete,InterpolateLinear,InterpolateSmooth,InterpolationSamplingMode,InterpolationSamplingType,KeyframeTrack,LOD,LatheGeometry,Layers,Light,Line,Line3,LineCurve,LineCurve3,LineLoop,LineSegments,LinearInterpolant,LinearMipMapNearestFilter,LoaderUtils,LoadingManager,LoopOnce,LoopPingPong,LoopRepeat,MOUSE,MeshDepthMaterial,MeshDistanceMaterial,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NormalAnimationBlendMode,NumberKeyframeTrack,OctahedronGeometry,OneMinusConstantAlphaFactor,OneMinusConstantColorFactor,PCFSoftShadowMap,Path,PlaneHelper,PointLightHelper,Points,PolarGridHelper,PolyhedronGeometry,PositionalAudio,PropertyBinding,PropertyMixer,QuadraticBezierCurve,QuadraticBezierCurve3,QuaternionKeyframeTrack,QuaternionLinearInterpolant,RGBADepthPacking,RGBDepthPacking,RGB_BPTC_SIGNED_Format,RGB_BPTC_UNSIGNED_Format,RGDepthPacking,RawShaderMaterial,Ray,Raycaster,RenderTarget3D,RingGeometry,ShaderMaterial,Shape,ShapeGeometry,ShapePath,ShapeUtils,Skeleton,SkeletonHelper,SkinnedMesh,Source,Spherical,SphericalHarmonics3,SplineCurve,SpotLightHelper,Sprite,StaticCopyUsage,StaticReadUsage,StereoCamera,StreamCopyUsage,StreamDrawUsage,StreamReadUsage,StringKeyframeTrack,TOUCH,TetrahedronGeometry,TextureLoader,TextureUtils,Timer,TimestampQuery,TorusGeometry,TorusKnotGeometry,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,VectorKeyframeTrack,VideoFrameTexture,VideoTexture,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGLRenderTarget,WireframeGeometry,WrapAroundEnding,ZeroCurvatureEnding,ZeroSlopeEnding}from"./three.core.min.js";const ms=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],fs=new WeakMap;class ys{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=ms,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:r,material:s,object:i}=e;if(t={material:this.getMaterialData(s),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e,t){const{object:r,material:s,geometry:i}=e,n=this.getRenderObjectData(e);if(!0!==n.worldMatrix.equals(r.matrixWorld))return n.worldMatrix.copy(r.matrixWorld),!1;const a=n.material;for(const e in a){const t=a[e],r=s[e];if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){const{width:t,height:r}=e.context;if(n.bufferWidth!==t||n.bufferHeight!==r)return n.bufferWidth=t,n.bufferHeight=r,!1}const o=n.geometry,u=i.attributes,l=o.attributes,d=Object.keys(l),c=Object.keys(u);if(o.id!==i.id)return o.id=i.id,!1;if(d.length!==c.length)return n.geometry.attributes=this.getAttributesData(u),!1;for(const e of d){const t=l[e],r=u[e];if(void 0===r)return delete l[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const h=i.index,p=o.indexVersion,g=h?h.version:null;if(p!==g)return o.indexVersion=g,!1;if(o.drawRange.start!==i.drawRange.start||o.drawRange.count!==i.drawRange.count)return o.drawRange.start=i.drawRange.start,o.drawRange.count=i.drawRange.count,!1;if(n.morphTargetInfluences){let e=!1;for(let t=0;t<n.morphTargetInfluences.length;t++)n.morphTargetInfluences[t]!==r.morphTargetInfluences[t]&&(e=!0);if(e)return!0}if(n.lights)for(let e=0;e<t.length;e++)if(n.lights[e].map!==t[e].map)return!1;return n.center&&!1===n.center.equals(r.center)?(n.center.copy(r.center),!0):(null!==e.bundle&&(n.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const r of e)!0===r.isSpotLight&&null!==r.map&&t.push({map:r.map.version});return t}getLights(e,t){if(fs.has(e)){const r=fs.get(e);if(r.renderId===t)return r.lightsData}const r=this.getLightsData(e.getLights());return fs.set(e,{renderId:t,lightsData:r}),r}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:r}=t;if(this.renderId!==r)return this.renderId=r,!0;const s=!0===e.object.static,i=null!==e.bundle&&!0===e.bundle.static&&this.getRenderObjectData(e).version===e.bundle.version;if(s||i)return!1;const n=this.getLights(e.lightsNode,r);return!0!==this.equals(e,n)}}function bs(e,t=0){let r=3735928559^t,s=1103547991^t;if(e instanceof Array)for(let t,i=0;i<e.length;i++)t=e[i],r=Math.imul(r^t,2654435761),s=Math.imul(s^t,1597334677);else for(let t,i=0;i<e.length;i++)t=e.charCodeAt(i),r=Math.imul(r^t,2654435761),s=Math.imul(s^t,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&s)+(r>>>0)}const xs=e=>bs(e),Ts=e=>bs(e),_s=(...e)=>bs(e);function vs(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of Ns(e))r.push(bs(s.slice(0,-4)),i.getCacheKey(t));return bs(r)}function*Ns(e,t=!1){for(const r in e){if(!0===r.startsWith("_"))continue;const s=e[r];if(!0===Array.isArray(s))for(let e=0;e<s.length;e++){const i=s[e];i&&(!0===i.isNode||t&&"function"==typeof i.toJSON)&&(yield{property:r,index:e,childNode:i})}else if(s&&!0===s.isNode)yield{property:r,childNode:s};else if(s&&Object.getPrototypeOf(s)===Object.prototype)for(const e in s){if(!0===e.startsWith("_"))continue;const i=s[e];i&&(!0===i.isNode||t&&"function"==typeof i.toJSON)&&(yield{property:r,index:e,childNode:i})}}}const Ss=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Es=new WeakMap;function ws(e){return Ss.get(e)}function As(e){if(/[iu]?vec\d/.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(e))return Float32Array;if(/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function Rs(e){return/float|int|uint/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?9:/mat4/.test(e)?16:void console.error("THREE.TSL: Unsupported type:",e)}function Cs(e){return/float|int|uint/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?12:/mat4/.test(e)?16:void console.error("THREE.TSL: Unsupported type:",e)}function Ms(e){return/float|int|uint/.test(e)?4:/vec2/.test(e)?8:/vec3/.test(e)||/vec4/.test(e)?16:/mat2/.test(e)?8:/mat3/.test(e)?48:/mat4/.test(e)?64:void console.error("THREE.TSL: Unsupported type:",e)}function Ps(e){if(null==e)return null;const t=typeof e;return!0===e.isNode?"node":"number"===t?"float":"boolean"===t?"bool":"string"===t?"string":"function"===t?"shader":!0===e.isVector2?"vec2":!0===e.isVector3?"vec3":!0===e.isVector4?"vec4":!0===e.isMatrix2?"mat2":!0===e.isMatrix3?"mat3":!0===e.isMatrix4?"mat4":!0===e.isColor?"color":e instanceof ArrayBuffer?"ArrayBuffer":null}function Bs(o,...u){const l=o?o.slice(-4):void 0;return 1===u.length&&("vec2"===l?u=[u[0],u[0]]:"vec3"===l?u=[u[0],u[0],u[0]]:"vec4"===l&&(u=[u[0],u[0],u[0],u[0]])),"color"===o?new e(...u):"vec2"===l?new t(...u):"vec3"===l?new r(...u):"vec4"===l?new s(...u):"mat2"===l?new i(...u):"mat3"===l?new n(...u):"mat4"===l?new a(...u):"bool"===o?u[0]||!1:"float"===o||"int"===o||"uint"===o?u[0]||0:"string"===o?u[0]||"":"ArrayBuffer"===o?Is(u[0]):null}function Ls(e){let t=Es.get(e);return void 0===t&&(t={},Es.set(e,t)),t}function Fs(e){let t="";const r=new Uint8Array(e);for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return btoa(t)}function Is(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0))).buffer}var Ds=Object.freeze({__proto__:null,arrayBufferToBase64:Fs,base64ToArrayBuffer:Is,getByteBoundaryFromType:Ms,getCacheKey:vs,getDataFromObject:Ls,getLengthFromType:Rs,getMemoryLengthFromType:Cs,getNodeChildren:Ns,getTypeFromLength:ws,getTypedArrayFromType:As,getValueFromType:Bs,getValueType:Ps,hash:_s,hashArray:Ts,hashString:xs});const Vs={VERTEX:"vertex",FRAGMENT:"fragment"},Us={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Os={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ks={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Gs=["fragment","vertex"],zs=["setup","analyze","generate"],Hs=[...Gs,"compute"],$s=["x","y","z","w"],Ws={analyze:"setup",generate:"analyze"};let qs=0;class js extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Us.NONE,this.updateBeforeType=Us.NONE,this.updateAfterType=Us.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:qs++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Us.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Us.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Us.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Ns(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=_s(vs(this,e),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(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let r=0;for(const e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(!0===this.parents){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=Ws[e.buildStage];if(i&&!0!==s.buildStages[i]){const t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null;const a=e.getBuildStage();if("setup"===a){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(const r of Object.values(t))if(r&&!0===r.isNode){if(!0===r.parents){const t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){const r=this.getNodeType(e),s=e.getDataFromNode(this);n=s.snippet,void 0===n?void 0===s.generated?(s.generated=!0,n=this.generate(e)||"",s.snippet=n):(console.warn("THREE.Node: Recursion detected.",this),n="/* Recursion detected. */"):void 0!==s.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return Ns(this)}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:i,childNode:n}of t)void 0!==i?(void 0===r[s]&&(r[s]=Number.isInteger(i)?[]:{}),r[s][i]=n.toJSON(e.meta).uuid):r[s]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const i of e.inputNodes[r])s.push(t[i]);this[r]=s}else if("object"==typeof e.inputNodes[r]){const s={};for(const i in e.inputNodes[r]){const n=e.inputNodes[r][i];s[i]=t[n]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=void 0===e||"string"==typeof e;s&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];function n(e){const t=[];for(const r in e){const s=e[r];delete s.metadata,t.push(s)}return t}if(void 0===i&&(i={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==s&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta),s){const t=n(e.textures),r=n(e.images),s=n(e.nodes);t.length>0&&(i.textures=t),r.length>0&&(i.images=r),s.length>0&&(i.nodes=s)}return i}}class Xs extends js{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e);return`${this.node.build(e)}[ ${this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint")} ]`}}class Ks extends js{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))null!==r&&e.getTypeLength(t)!==e.getTypeLength(s)||(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),i=r.build(e,s);return e.format(i,s,t)}}class Ys extends js{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const r=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(void 0!==s.propertyName)return e.format(s.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){const i=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${i}`,this),s.snippet=i,s.propertyName=a,e.format(s.propertyName,r,t)}}return super.build(e,t)}}class Qs extends Ys{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,r)=>t+e.getTypeLength(r.getNodeType(e))),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),i=this.nodes,n=e.getComponentType(r),a=[];let o=0;for(const t of i){if(o>=s){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,u=t.getNodeType(e),l=e.getTypeLength(u);o+l>s&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),l=s-o,u=e.getTypeFromLength(l)),o+=l,i=t.build(e,u);const d=e.getComponentType(u);d!==n&&(i=e.format(i,d,n)),a.push(i)}const u=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(u,r,t)}}const Zs=$s.join("");class Js extends js{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max($s.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let i=null;if(s>1){let n=null;this.getVectorLength()>=s&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const a=r.build(e,n);i=this.components.length===s&&this.components===Zs.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else i=r.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class ei extends Ys{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,i=this.getNodeType(e),n=e.getComponentType(s.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=s.build(e,a),u=t.build(e,i),l=e.getTypeLength(i),d=[];for(let e=0;e<l;e++){const t=$s[e];t===r[0]?(d.push(o),e+=r.length-1):d.push(u+"."+t)}return`${e.getType(i)}( ${d.join(", ")} )`}}class ti extends Ys{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:r}=this,s=this.getNodeType(e),i=r.build(e),n=e.getVarFromNode(this),a=e.getPropertyName(n);e.addLineFlowCode(a+" = "+i,this);const o=e.getTypeLength(s),u=[];let l=0;for(let e=0;e<o;e++){const r=$s[e];r===t[l]?(u.push("1.0 - "+a+"."+r),l++):u.push(a+"."+r)}return`${e.getType(s)}( ${u.join(", ")} )`}}class ri extends js{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return null===this.nodeType?Ps(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Ps(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=Fs(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Bs(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const si=/float|u?int/;class ii extends ri{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const r=this.getNodeType(e);return si.test(r)&&si.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class ni extends js{static get type(){return"MemberNode"}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}}let ai=null;const oi=new Map;function ui(e,t){if(oi.has(e))console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);else{if("function"!=typeof t)throw new Error(`THREE.TSL: Node element ${e} is not a function`);oi.set(e,t)}}const li=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),di=e=>li(e).split("").sort().join(""),ci={setup(e,t){const r=t.shift();return e(Vi(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ai.assign(r,...e),r);if(oi.has(t)){const s=oi.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("toVarIntent"===t)return()=>r;if("self"===t)return e;if(t.endsWith("Assign")&&oi.has(t.slice(0,t.length-6))){const s=oi.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],s(...e)):(...e)=>r.assign(s(r,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=li(t),Ii(new Js(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=di(t.slice(3).toLowerCase()),r=>Ii(new ei(e,t,Ii(r)));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=di(t.slice(4).toLowerCase()),()=>Ii(new ti(Ii(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Ii(new Js(e,t));if(!0===/^\d+$/.test(t))return Ii(new Xs(r,new ii(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Ii(new ni(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,s)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,r,s):(s[t].assign(r),!0)},hi=new WeakMap,pi=new WeakMap,gi=function(e,t=null){for(const r in e)e[r]=Ii(e[r],t);return e},mi=function(e,t=null){const r=e.length;for(let s=0;s<r;s++)e[s]=Ii(e[s],t);return e},fi=function(e,t=null,r=null,s=null){function i(e){return null!==s?(e=Ii(Object.assign(e,s)),!0===s.intent&&(e=e.toVarIntent())):e=Ii(e),e}let n,a,o,u=t;function l(t){let r;return r=u?/[a-z]/i.test(u)?u+"()":u:e.type,void 0!==a&&t.length<a?(console.error(`THREE.TSL: "${r}" parameter length is less than minimum required.`),t.concat(new Array(a-t.length).fill(0))):void 0!==o&&t.length>o?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,o)):t}return null===t?n=(...t)=>i(new e(...Ui(l(t)))):null!==r?(r=Ii(r),n=(...s)=>i(new e(t,...Ui(l(s)),r))):n=(...r)=>i(new e(t,...Ui(l(r)))),n.setParameterLength=(...e)=>(1===e.length?a=o=e[0]:2===e.length&&([a,o]=e),n),n.setName=e=>(u=e,n),n},yi=function(e,...t){return Ii(new e(...Ui(t)))};class bi extends js{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:r}=this,s=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||"",n=i||"default";if(s[n])return s[n];const a=e.subBuildFn;e.subBuildFn=i;let o=null;if(t.layout){let s=pi.get(e.constructor);void 0===s&&(s=new WeakMap,pi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Ii(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i),o=Ii(i.call(r))}else{let s=r;if(Array.isArray(s)){let e=0;s=new Proxy(s,{get:(t,r,s)=>void 0===t[r]?t[e++]:Reflect.get(t,r,s)})}const i=t.jsFunc,n=null!==s||i.length>1?i(s||[],e):i(e);o=Ii(n)}return e.subBuildFn=a,t.once&&(s[n]=o),o}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),i=e.getNodeProperties(this),n=e.getSubBuildOutput(this),a=this.getOutputNode(e);if("setup"===s){const t=e.getSubBuildProperty("initialized",this);if(!0!==i[t]&&(i[t]=!0,i[n]=this.getOutputNode(e),i[n].build(e),this.shaderNode.subBuilds))for(const t of e.chaining){const r=e.getDataFromNode(t,"any");r.subBuilds=r.subBuilds||new Set;for(const e of this.shaderNode.subBuilds)r.subBuilds.add(e)}r=i[n]}else"analyze"===s?a.build(e,t):"generate"===s&&(r=a.build(e,t)||"");return r}}class xi extends js{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Vi(e),Ii(new bi(this,e))}setup(){return this.call()}}const Ti=[!1,!0],_i=[0,1,2,3],vi=[-1,-2],Ni=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Si=new Map;for(const e of Ti)Si.set(e,new ii(e));const Ei=new Map;for(const e of _i)Ei.set(e,new ii(e,"uint"));const wi=new Map([...Ei].map((e=>new ii(e.value,"int"))));for(const e of vi)wi.set(e,new ii(e,"int"));const Ai=new Map([...wi].map((e=>new ii(e.value))));for(const e of Ni)Ai.set(e,new ii(e));for(const e of Ni)Ai.set(-e,new ii(-e));const Ri={bool:Si,uint:Ei,ints:wi,float:Ai},Ci=new Map([...Si,...Ai]),Mi=(e,t)=>Ci.has(e)?Ci.get(e):!0===e.isNode?e:new ii(e,t),Pi=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Bs(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Di(t.get(r[0]));if(1===r.length){const t=Mi(r[0],e);return t.nodeType===e?Di(t):Di(new Ks(t,e))}const s=r.map((e=>Mi(e)));return Di(new Qs(s,e))}},Bi=e=>"object"==typeof e&&null!==e?e.value:e,Li=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Fi(e,t){return new Proxy(new xi(e,t),ci)}const Ii=(e,t=null)=>function(e,t=null){const r=Ps(e);if("node"===r){let t=hi.get(e);return void 0===t&&(t=new Proxy(e,ci),hi.set(e,t),hi.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Ii(Mi(e,t)):"shader"===r?e.isFn?e:Hi(e):e}(e,t),Di=(e,t=null)=>Ii(e,t).toVarIntent(),Vi=(e,t=null)=>new gi(e,t),Ui=(e,t=null)=>new mi(e,t),Oi=(e,t=null,r=null,s=null)=>new fi(e,t,r,s),ki=(e,...t)=>new yi(e,...t),Gi=(e,t=null,r=null,s={})=>new fi(e,t,r,{intent:!0,...s});let zi=0;const Hi=(e,t=null)=>{let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null));const s=new Fi(e,r),i=(...e)=>{let t;Vi(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];const i=s.call(t);return"void"===r&&i.toStack(),i.toVarIntent()};if(i.shaderNode=s,i.id=s.id,i.isFn=!0,i.getNodeType=(...e)=>s.getNodeType(...e),i.getCacheKey=(...e)=>s.getCacheKey(...e),i.setLayout=e=>(s.setLayout(e),i),i.once=(e=null)=>(s.once=!0,s.subBuilds=e,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+zi++,type:r,inputs:[]};for(const r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}i.setLayout(t)}return i},$i=e=>{ai=e},Wi=()=>ai,qi=(...e)=>ai.If(...e);function ji(e){return ai&&ai.add(e),e}ui("toStack",ji);const Xi=new Pi("color"),Ki=new Pi("float",Ri.float),Yi=new Pi("int",Ri.ints),Qi=new Pi("uint",Ri.uint),Zi=new Pi("bool",Ri.bool),Ji=new Pi("vec2"),en=new Pi("ivec2"),tn=new Pi("uvec2"),rn=new Pi("bvec2"),sn=new Pi("vec3"),nn=new Pi("ivec3"),an=new Pi("uvec3"),on=new Pi("bvec3"),un=new Pi("vec4"),ln=new Pi("ivec4"),dn=new Pi("uvec4"),cn=new Pi("bvec4"),hn=new Pi("mat2"),pn=new Pi("mat3"),gn=new Pi("mat4");ui("toColor",Xi),ui("toFloat",Ki),ui("toInt",Yi),ui("toUint",Qi),ui("toBool",Zi),ui("toVec2",Ji),ui("toIVec2",en),ui("toUVec2",tn),ui("toBVec2",rn),ui("toVec3",sn),ui("toIVec3",nn),ui("toUVec3",an),ui("toBVec3",on),ui("toVec4",un),ui("toIVec4",ln),ui("toUVec4",dn),ui("toBVec4",cn),ui("toMat2",hn),ui("toMat3",pn),ui("toMat4",gn);const mn=Oi(Xs).setParameterLength(2),fn=(e,t)=>Ii(new Ks(Ii(e),t));ui("element",mn),ui("convert",fn);ui("append",(e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),ji(e))));class yn extends js{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const bn=(e,t)=>Ii(new yn(e,t)),xn=(e,t)=>Ii(new yn(e,t,!0)),Tn=ki(yn,"vec4","DiffuseColor"),_n=ki(yn,"vec3","EmissiveColor"),vn=ki(yn,"float","Roughness"),Nn=ki(yn,"float","Metalness"),Sn=ki(yn,"float","Clearcoat"),En=ki(yn,"float","ClearcoatRoughness"),wn=ki(yn,"vec3","Sheen"),An=ki(yn,"float","SheenRoughness"),Rn=ki(yn,"float","Iridescence"),Cn=ki(yn,"float","IridescenceIOR"),Mn=ki(yn,"float","IridescenceThickness"),Pn=ki(yn,"float","AlphaT"),Bn=ki(yn,"float","Anisotropy"),Ln=ki(yn,"vec3","AnisotropyT"),Fn=ki(yn,"vec3","AnisotropyB"),In=ki(yn,"color","SpecularColor"),Dn=ki(yn,"float","SpecularF90"),Vn=ki(yn,"float","Shininess"),Un=ki(yn,"vec4","Output"),On=ki(yn,"float","dashSize"),kn=ki(yn,"float","gapSize"),Gn=ki(yn,"float","pointWidth"),zn=ki(yn,"float","IOR"),Hn=ki(yn,"float","Transmission"),$n=ki(yn,"float","Thickness"),Wn=ki(yn,"float","AttenuationDistance"),qn=ki(yn,"color","AttenuationColor"),jn=ki(yn,"float","Dispersion");class Xn extends js{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const Kn=e=>new Xn(e),Yn=(e,t=0)=>new Xn(e,!0,t),Qn=Yn("frame"),Zn=Yn("render"),Jn=Kn("object");class ea extends ri{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Jn}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const r=this.getSelf();return e=e.bind(r),super.onUpdate((t=>{const s=e(t,r);void 0!==s&&(this.value=s)}),t)}getInputType(e){let t=super.getInputType(e);return"bool"===t&&(t="uint"),t}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let i=e.getNodeFromHash(s);void 0===i&&(e.setHashNode(this,s),i=this);const n=i.getInputType(e),a=e.getUniformFromNode(i,n,e.shaderStage,this.name||e.context.nodeName),o=e.getPropertyName(a);void 0!==e.context.nodeName&&delete e.context.nodeName;let u=o;if("bool"===r){const t=e.getDataFromNode(this);let s=t.propertyName;if(void 0===s){const i=e.getVarFromNode(this,null,"bool");s=e.getPropertyName(i),t.propertyName=s,u=e.format(o,n,r),e.addLineFlowCode(`${s} = ${u}`,this)}u=s}return e.format(u,r,t)}}const ta=(e,t)=>{const r=Li(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Ii(new ea(s,r))};class ra extends Ys{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const sa=(...e)=>{let t;if(1===e.length){const r=e[0];t=new ra(null,r.length,r)}else{const r=e[0],s=e[1];t=new ra(r,s)}return Ii(t)};ui("toArray",((e,t)=>sa(Array(t).fill(e))));class ia extends Ys{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return $s.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this;e.getNodeProperties(t).assign=!0;const s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.build(e),o=s.build(e,n),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=a);else if(i){const s=e.getVarFromNode(this,null,n),i=e.getPropertyName(s);e.addLineFlowCode(`${i} = ${o}`,this);const u=r.node,l=u.node.context({assign:!0}).build(e);for(let t=0;t<u.components.length;t++){const r=u.components[t];e.addLineFlowCode(`${l}.${r} = ${i}[ ${t} ]`,this)}"void"!==t&&(d=a)}else d=`${a} = ${o}`,"void"!==t&&"void"!==u||(e.addLineFlowCode(d,this),"void"!==t&&(d=a));return l.initialized=!0,e.format(d,n,t)}}const na=Oi(ia).setParameterLength(2);ui("assign",na);class aa extends Ys{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],r=this.functionNode,s=r.getInputs(e),i=this.parameters,n=(t,r)=>{const s=r.type;let i;return i="pointer"===s?"&"+t.build(e):t.build(e,s),i};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(Ki(0));for(let e=0;e<i.length;e++)t.push(n(i[e],s[e]))}else for(const e of s){const r=i[e.name];void 0!==r?t.push(n(r,e)):(console.error(`THREE.TSL: Input '${e.name}' not found in 'Fn()'.`),t.push(n(Ki(0),e)))}return`${r.build(e,"property")}( ${t.join(", ")} )`}}const oa=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?Ui(t):Vi(t[0]),Ii(new aa(Ii(e),t)));ui("call",oa);const ua={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class la extends Ys{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new la(e,t,r);for(let t=0;t<s.length-1;t++)i=new la(e,i,s[t]);t=i,r=s[s.length-1]}this.op=e,this.aNode=t,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(ua[this.op],t)}getNodeType(e){const t=this.op,r=this.aNode,s=this.bNode,i=r.getNodeType(e),n=s?s.getNodeType(e):null;if("void"===i||"void"===n)return"void";if("%"===t)return i;if("~"===t||"&"===t||"|"===t||"^"===t||">>"===t||"<<"===t)return e.getIntegerType(i);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){const t=Math.max(e.getTypeLength(i),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}if(e.isMatrix(i)){if("float"===n)return i;if(e.isVector(n))return e.getVectorFromMatrix(i);if(e.isMatrix(n))return i}else if(e.isMatrix(n)){if("float"===i)return n;if(e.isVector(i))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(i)?n:i}generate(e,t){const r=this.op,{aNode:s,bNode:i}=this,n=this.getNodeType(e);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;const u=s.build(e,a),d=i?i.build(e,o):null,c=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(c)return e.format(`${c}( ${u}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${d}`,n,t);{let i=`( ${u} ${r} ${d} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return c?e.format(`${c}( ${u}, ${d} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${d} ${r} ${u}`,n,t):e.format(`${u} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const da=Gi(la,"+").setParameterLength(2,1/0).setName("add"),ca=Gi(la,"-").setParameterLength(2,1/0).setName("sub"),ha=Gi(la,"*").setParameterLength(2,1/0).setName("mul"),pa=Gi(la,"/").setParameterLength(2,1/0).setName("div"),ga=Gi(la,"%").setParameterLength(2).setName("mod"),ma=Gi(la,"==").setParameterLength(2).setName("equal"),fa=Gi(la,"!=").setParameterLength(2).setName("notEqual"),ya=Gi(la,"<").setParameterLength(2).setName("lessThan"),ba=Gi(la,">").setParameterLength(2).setName("greaterThan"),xa=Gi(la,"<=").setParameterLength(2).setName("lessThanEqual"),Ta=Gi(la,">=").setParameterLength(2).setName("greaterThanEqual"),_a=Gi(la,"&&").setParameterLength(2,1/0).setName("and"),va=Gi(la,"||").setParameterLength(2,1/0).setName("or"),Na=Gi(la,"!").setParameterLength(1).setName("not"),Sa=Gi(la,"^^").setParameterLength(2).setName("xor"),Ea=Gi(la,"&").setParameterLength(2).setName("bitAnd"),wa=Gi(la,"~").setParameterLength(2).setName("bitNot"),Aa=Gi(la,"|").setParameterLength(2).setName("bitOr"),Ra=Gi(la,"^").setParameterLength(2).setName("bitXor"),Ca=Gi(la,"<<").setParameterLength(2).setName("shiftLeft"),Ma=Gi(la,">>").setParameterLength(2).setName("shiftRight"),Pa=Hi((([e])=>(e.addAssign(1),e))),Ba=Hi((([e])=>(e.subAssign(1),e))),La=Hi((([e])=>{const t=Yi(e).toConst();return e.addAssign(1),t})),Fa=Hi((([e])=>{const t=Yi(e).toConst();return e.subAssign(1),t}));ui("add",da),ui("sub",ca),ui("mul",ha),ui("div",pa),ui("mod",ga),ui("equal",ma),ui("notEqual",fa),ui("lessThan",ya),ui("greaterThan",ba),ui("lessThanEqual",xa),ui("greaterThanEqual",Ta),ui("and",_a),ui("or",va),ui("not",Na),ui("xor",Sa),ui("bitAnd",Ea),ui("bitNot",wa),ui("bitOr",Aa),ui("bitXor",Ra),ui("shiftLeft",Ca),ui("shiftRight",Ma),ui("incrementBefore",Pa),ui("decrementBefore",Ba),ui("increment",La),ui("decrement",Fa);const Ia=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),ga(Yi(e),Yi(t)));ui("modInt",Ia);class Da extends Ys{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Da.MAX||e===Da.MIN)&&arguments.length>3){let i=new Da(e,t,r);for(let t=2;t<arguments.length-1;t++)i=new Da(e,i,arguments[t]);t=i,r=arguments[arguments.length-1],s=null}this.method=e,this.aNode=t,this.bNode=r,this.cNode=s,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),r=this.bNode?this.bNode.getNodeType(e):null,s=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(r)?0:e.getTypeLength(r),a=e.isMatrix(s)?0:e.getTypeLength(s);return i>n&&i>a?t:n>a?r:a>i?s:t}getNodeType(e){const t=this.method;return t===Da.LENGTH||t===Da.DISTANCE||t===Da.DOT?"float":t===Da.CROSS?"vec3":t===Da.ALL||t===Da.ANY?"bool":t===Da.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let i=null;if(s===Da.ONE_MINUS)i=ca(1,t);else if(s===Da.RECIPROCAL)i=pa(1,t);else if(s===Da.DIFFERENCE)i=oo(ca(t,r));else if(s===Da.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=un(sn(n),0):s=un(sn(s),0);const a=ha(s,n).xyz;i=Ja(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===Da.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const c=[];return r===Da.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===Da.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==Da.MIN&&r!==Da.MAX?r===Da.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===Da.MIX?c.push(n.build(e,i),a.build(e,i),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":i)):(u===d&&r===Da.ATAN&&null!==a&&(r="atan2"),"fragment"===e.shaderStage||r!==Da.DFDX&&r!==Da.DFDY||(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),c.push(n.build(e,i)),null!==a&&c.push(a.build(e,i)),null!==o&&c.push(o.build(e,i))):c.push(n.build(e,i),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":i)),e.format(`${e.getMethod(r,s)}( ${c.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Da.ALL="all",Da.ANY="any",Da.RADIANS="radians",Da.DEGREES="degrees",Da.EXP="exp",Da.EXP2="exp2",Da.LOG="log",Da.LOG2="log2",Da.SQRT="sqrt",Da.INVERSE_SQRT="inversesqrt",Da.FLOOR="floor",Da.CEIL="ceil",Da.NORMALIZE="normalize",Da.FRACT="fract",Da.SIN="sin",Da.COS="cos",Da.TAN="tan",Da.ASIN="asin",Da.ACOS="acos",Da.ATAN="atan",Da.ABS="abs",Da.SIGN="sign",Da.LENGTH="length",Da.NEGATE="negate",Da.ONE_MINUS="oneMinus",Da.DFDX="dFdx",Da.DFDY="dFdy",Da.ROUND="round",Da.RECIPROCAL="reciprocal",Da.TRUNC="trunc",Da.FWIDTH="fwidth",Da.TRANSPOSE="transpose",Da.DETERMINANT="determinant",Da.INVERSE="inverse",Da.BITCAST="bitcast",Da.EQUALS="equals",Da.MIN="min",Da.MAX="max",Da.STEP="step",Da.REFLECT="reflect",Da.DISTANCE="distance",Da.DIFFERENCE="difference",Da.DOT="dot",Da.CROSS="cross",Da.POW="pow",Da.TRANSFORM_DIRECTION="transformDirection",Da.MIX="mix",Da.CLAMP="clamp",Da.REFRACT="refract",Da.SMOOTHSTEP="smoothstep",Da.FACEFORWARD="faceforward";const Va=Ki(1e-6),Ua=Ki(1e6),Oa=Ki(Math.PI),ka=Ki(2*Math.PI),Ga=Gi(Da,Da.ALL).setParameterLength(1),za=Gi(Da,Da.ANY).setParameterLength(1),Ha=Gi(Da,Da.RADIANS).setParameterLength(1),$a=Gi(Da,Da.DEGREES).setParameterLength(1),Wa=Gi(Da,Da.EXP).setParameterLength(1),qa=Gi(Da,Da.EXP2).setParameterLength(1),ja=Gi(Da,Da.LOG).setParameterLength(1),Xa=Gi(Da,Da.LOG2).setParameterLength(1),Ka=Gi(Da,Da.SQRT).setParameterLength(1),Ya=Gi(Da,Da.INVERSE_SQRT).setParameterLength(1),Qa=Gi(Da,Da.FLOOR).setParameterLength(1),Za=Gi(Da,Da.CEIL).setParameterLength(1),Ja=Gi(Da,Da.NORMALIZE).setParameterLength(1),eo=Gi(Da,Da.FRACT).setParameterLength(1),to=Gi(Da,Da.SIN).setPa