UNPKG

three

Version:

JavaScript 3D library

6 lines 532 kB
/** * @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,InterleavedBufferAttribute as f,DynamicDrawUsage as y,NoColorSpace as x,UnsignedIntType as b,IntType as T,NearestFilter as _,Sphere as v,BackSide as N,Euler as S,CubeReflectionMapping as E,CubeRefractionMapping as w,TangentSpaceNormalMap as A,ObjectSpaceNormalMap as R,InstancedInterleavedBuffer as C,InstancedBufferAttribute as M,DataArrayTexture as P,FloatType as L,FramebufferTexture as F,LinearMipmapLinearFilter as B,DepthTexture as I,Material as D,NormalBlending as V,LineBasicMaterial as U,LineDashedMaterial as O,NoBlending as G,MeshNormalMaterial as k,SRGBColorSpace as z,WebGLCubeRenderTarget as $,BoxGeometry as H,Mesh as W,Scene as j,LinearFilter as q,CubeCamera as X,CubeTexture as K,EquirectangularReflectionMapping as Y,EquirectangularRefractionMapping as Q,AddOperation as Z,MixOperation as J,MultiplyOperation as ee,MeshBasicMaterial as te,MeshLambertMaterial as re,MeshPhongMaterial as se,OrthographicCamera as ie,PerspectiveCamera as ne,RenderTarget as ae,CubeUVReflectionMapping as oe,BufferGeometry as ue,BufferAttribute as le,LinearSRGBColorSpace as de,RGBAFormat as ce,HalfFloatType as he,Texture as pe,MeshStandardMaterial as ge,MeshPhysicalMaterial as me,MeshToonMaterial as fe,MeshMatcapMaterial as ye,SpriteMaterial as xe,PointsMaterial as be,ShadowMaterial as Te,Uint32BufferAttribute as _e,Uint16BufferAttribute as ve,arrayNeedsUint32 as Ne,DoubleSide 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 Le,Float32BufferAttribute as Fe,UVMapping as Be,LessCompare as Ie,VSMShadowMap as De,RGFormat as Ve,BasicShadowMap as Ue,SphereGeometry as Oe,LinearMipmapNearestFilter as Ge,NearestMipmapLinearFilter as ke,Float16BufferAttribute as ze,REVISION as $e,ArrayCamera as He,PlaneGeometry as We,FrontSide as je,CustomBlending as qe,AddEquation as Xe,ZeroFactor as Ke,CylinderGeometry as Ye,Quaternion as Qe,WebXRController as Ze,RAD2DEG as Je,PCFShadowMap as et,Frustum as tt,DataTexture as rt,RedIntegerFormat as st,RedFormat as it,ShortType as nt,ByteType as at,UnsignedShortType as ot,RGIntegerFormat as ut,RGBIntegerFormat as lt,RGBFormat as dt,RGBAIntegerFormat as ct,warnOnce as ht,createCanvasElement as pt,ReverseSubtractEquation as gt,SubtractEquation as mt,OneMinusDstAlphaFactor as ft,OneMinusDstColorFactor as yt,OneMinusSrcAlphaFactor as xt,OneMinusSrcColorFactor as bt,DstAlphaFactor as Tt,DstColorFactor as _t,SrcAlphaSaturateFactor as vt,SrcAlphaFactor as Nt,SrcColorFactor as St,OneFactor as Et,CullFaceNone as wt,CullFaceBack as At,CullFaceFront as Rt,MultiplyBlending as Ct,SubtractiveBlending as Mt,AdditiveBlending as Pt,NotEqualDepth as Lt,GreaterDepth as Ft,GreaterEqualDepth as Bt,EqualDepth as It,LessEqualDepth as Dt,LessDepth as Vt,AlwaysDepth as Ut,NeverDepth as Ot,UnsignedShort4444Type as Gt,UnsignedShort5551Type as kt,UnsignedInt5999Type as zt,AlphaFormat as $t,LuminanceFormat as Ht,LuminanceAlphaFormat as Wt,RGB_S3TC_DXT1_Format as jt,RGBA_S3TC_DXT1_Format as qt,RGBA_S3TC_DXT3_Format as Xt,RGBA_S3TC_DXT5_Format as Kt,RGB_PVRTC_4BPPV1_Format as Yt,RGB_PVRTC_2BPPV1_Format as Qt,RGBA_PVRTC_4BPPV1_Format as Zt,RGBA_PVRTC_2BPPV1_Format as Jt,RGB_ETC1_Format as er,RGB_ETC2_Format as tr,RGBA_ETC2_EAC_Format as rr,RGBA_ASTC_4x4_Format as sr,RGBA_ASTC_5x4_Format as ir,RGBA_ASTC_5x5_Format as nr,RGBA_ASTC_6x5_Format as ar,RGBA_ASTC_6x6_Format as or,RGBA_ASTC_8x5_Format as ur,RGBA_ASTC_8x6_Format as lr,RGBA_ASTC_8x8_Format as dr,RGBA_ASTC_10x5_Format as cr,RGBA_ASTC_10x6_Format as hr,RGBA_ASTC_10x8_Format as pr,RGBA_ASTC_10x10_Format as gr,RGBA_ASTC_12x10_Format as mr,RGBA_ASTC_12x12_Format as fr,RGBA_BPTC_Format as yr,RED_RGTC1_Format as xr,SIGNED_RED_RGTC1_Format as br,RED_GREEN_RGTC2_Format as Tr,SIGNED_RED_GREEN_RGTC2_Format as _r,MirroredRepeatWrapping as vr,ClampToEdgeWrapping as Nr,RepeatWrapping as Sr,NearestMipmapNearestFilter as Er,NotEqualCompare as wr,GreaterCompare as Ar,GreaterEqualCompare as Rr,EqualCompare as Cr,LessEqualCompare as Mr,AlwaysCompare as Pr,NeverCompare as Lr,NotEqualStencilFunc as Fr,GreaterStencilFunc as Br,GreaterEqualStencilFunc as Ir,EqualStencilFunc as Dr,LessEqualStencilFunc as Vr,LessStencilFunc as Ur,AlwaysStencilFunc as Or,NeverStencilFunc as Gr,DecrementWrapStencilOp as kr,IncrementWrapStencilOp as zr,DecrementStencilOp as $r,IncrementStencilOp as Hr,InvertStencilOp as Wr,ReplaceStencilOp as jr,ZeroStencilOp as qr,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,KeyframeTrack,LOD,LatheGeometry,Layers,Light,Line,Line3,LineCurve,LineCurve3,LineLoop,LineSegments,LinearInterpolant,LinearMipMapNearestFilter,LinearTransfer,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,RenderTargetArray,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,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","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class fs{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)}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}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.nodes.modelViewMatrix||null!==e.renderer.nodes.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){const{object:t,material:r,geometry:s}=e,i=this.getRenderObjectData(e);if(!0!==i.worldMatrix.equals(t.matrixWorld))return i.worldMatrix.copy(t.matrixWorld),!1;const n=i.material;for(const e in n){const t=n[e],s=r[e];if(void 0!==t.equals){if(!1===t.equals(s))return t.copy(s),!1}else if(!0===s.isTexture){if(t.id!==s.id||t.version!==s.version)return t.id=s.id,t.version=s.version,!1}else if(t!==s)return n[e]=s,!1}if(n.transmission>0){const{width:t,height:r}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==r)return i.bufferWidth=t,i.bufferHeight=r,!1}const a=i.geometry,o=s.attributes,u=a.attributes,l=Object.keys(u),d=Object.keys(o);if(a.id!==s.id)return a.id=s.id,!1;if(l.length!==d.length)return i.geometry.attributes=this.getAttributesData(o),!1;for(const e of l){const t=u[e],r=o[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const c=s.index,h=a.indexVersion,p=c?c.version:null;if(h!==p)return a.indexVersion=p,!1;if(a.drawRange.start!==s.drawRange.start||a.drawRange.count!==s.drawRange.count)return a.drawRange.start=s.drawRange.start,a.drawRange.count=s.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let r=0;r<i.morphTargetInfluences.length;r++)i.morphTargetInfluences[r]!==t.morphTargetInfluences[r]&&(e=!0);if(e)return!0}return i.center&&!1===i.center.equals(t.center)?(i.center.copy(t.center),!0):(null!==e.bundle&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))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;return!0!==this.equals(e)}}function ys(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=>ys(e),bs=e=>ys(e),Ts=(...e)=>ys(e);function _s(e,t=!1){const r=[];!0===e.isNode&&(r.push(e.id),e=e.getSelf());for(const{property:s,childNode:i}of vs(e))r.push(ys(s.slice(0,-4)),i.getCacheKey(t));return ys(r)}function*vs(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("object"==typeof s)for(const e in s){const i=s[e];i&&(!0===i.isNode||t&&"function"==typeof i.toJSON)&&(yield{property:r,index:e,childNode:i})}}}const Ns=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Ss=new WeakMap;function Es(e){return Ns.get(e)}function ws(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 As(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 Rs(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 Cs(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?Ls(u[0]):null}function Ms(e){let t=Ss.get(e);return void 0===t&&(t={},Ss.set(e,t)),t}function Ps(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 Ls(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0))).buffer}var Fs=Object.freeze({__proto__:null,arrayBufferToBase64:Ps,base64ToArrayBuffer:Ls,getCacheKey:_s,getDataFromObject:Ms,getLengthFromType:As,getNodeChildren:vs,getTypeFromLength:Es,getTypedArrayFromType:ws,getValueFromType:Cs,getValueType:Rs,hash:Ts,hashArray:bs,hashString:xs});const Bs={VERTEX:"vertex",FRAGMENT:"fragment"},Is={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Ds={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Vs={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Us=["fragment","vertex"],Os=["setup","analyze","generate"],Gs=[...Us,"compute"],ks=["x","y","z","w"];let zs=0;class $s extends o{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Is.NONE,this.updateBeforeType=Is.NONE,this.updateAfterType=Is.NONE,this.uuid=u.generateUUID(),this.version=0,this.global=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:zs++})}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,Is.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Is.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Is.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 vs(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=Ts(_s(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}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){if(1===e.increaseUsage(this)){const t=e.getNodeProperties(this);for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e)}}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);e.addNode(this),e.addChain(this);let s=null;const i=e.getBuildStage();if("setup"===i){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){t.initialized=!0;const r=this.setup(e),s=r&&!0===r.isNode;for(const r of Object.values(t))r&&!0===r.isNode&&r.build(e);s&&r.build(e),t.outputNode=r}}else if("analyze"===i)this.analyze(e);else if("generate"===i){if(1===this.generate.length){const r=this.getNodeType(e),i=e.getDataFromNode(this);s=i.snippet,void 0===s?void 0===i.generated?(i.generated=!0,s=this.generate(e)||"",i.snippet=s):(console.warn("THREE.Node: Recursion detected.",this),s=""):void 0!==i.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),s=e.format(s,r,t)}else s=this.generate(e,t)||""}return e.removeChain(this),e.addSequentialNode(this),s}getSerializeChildren(){return vs(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.6,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 Hs extends $s{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 Ws extends $s{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 js extends $s{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 js{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 Xs=ks.join("");class Ks extends $s{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(ks.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===Xs.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 Ys extends js{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=ks[e];t===r[0]?(d.push(o),e+=r.length-1):d.push(u+"."+t)}return`${e.getType(i)}( ${d.join(", ")} )`}}class Qs extends js{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=ks[e];r===t[l]?(u.push("1.0 - "+a+"."+r),l++):u.push(a+"."+r)}return`${e.getType(s)}( ${u.join(", ")} )`}}class Zs extends $s{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?Rs(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=Rs(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=Ps(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Cs(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 Js=/float|u?int/;class ei extends Zs{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 Js.test(r)&&Js.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class ti extends $s{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 ri=null;const si=new Map;function ii(e,t){if(si.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`);si.set(e,t)}}const ni=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),ai=e=>ni(e).split("").sort().join(""),oi={setup(e,t){const r=t.shift();return e(Li(r),...t)},get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(ri.assign(r,...e),r);if(si.has(t)){const s=si.get(t);return e.isStackNode?(...e)=>r.add(s(...e)):(...e)=>s(r,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&si.has(t.slice(0,t.length-6))){const s=si.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=ni(t),Pi(new Ks(r,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=ai(t.slice(3).toLowerCase()),r=>Pi(new Ys(e,t,r));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=ai(t.slice(4).toLowerCase()),()=>Pi(new Qs(Pi(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Pi(new Ks(e,t));if(!0===/^\d+$/.test(t))return Pi(new Hs(r,new ei(Number(t),"uint")));if(!0===/^get$/.test(t))return e=>Pi(new ti(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)},ui=new WeakMap,li=new WeakMap,di=function(e,t=null){for(const r in e)e[r]=Pi(e[r],t);return e},ci=function(e,t=null){const r=e.length;for(let s=0;s<r;s++)e[s]=Pi(e[s],t);return e},hi=function(e,t=null,r=null,s=null){const i=e=>Pi(null!==s?Object.assign(e,s):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(...Fi(l(t)))):null!==r?(r=Pi(r),n=(...s)=>i(new e(t,...Fi(l(s)),r))):n=(...r)=>i(new e(t,...Fi(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},pi=function(e,...t){return Pi(new e(...Fi(t)))};class gi extends $s{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}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);if(s.onceOutput)return s.onceOutput;let i=null;if(t.layout){let s=li.get(e.constructor);void 0===s&&(s=new WeakMap,li.set(e.constructor,s));let n=s.get(t);void 0===n&&(n=Pi(e.buildFunctionNode(t)),s.set(t,n)),e.addInclude(n),i=Pi(n.call(r))}else{const s=t.jsFunc,n=null!==r||s.length>1?s(r||[],e):s(e);i=Pi(n)}return t.once&&(s.onceOutput=i),i}getOutputNode(e){const t=e.getNodeProperties(this);return null===t.outputNode&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class mi extends $s{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 Li(e),Pi(new gi(this,e))}setup(){return this.call()}}const fi=[!1,!0],yi=[0,1,2,3],xi=[-1,-2],bi=[.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],Ti=new Map;for(const e of fi)Ti.set(e,new ei(e));const _i=new Map;for(const e of yi)_i.set(e,new ei(e,"uint"));const vi=new Map([..._i].map((e=>new ei(e.value,"int"))));for(const e of xi)vi.set(e,new ei(e,"int"));const Ni=new Map([...vi].map((e=>new ei(e.value))));for(const e of bi)Ni.set(e,new ei(e));for(const e of bi)Ni.set(-e,new ei(-e));const Si={bool:Ti,uint:_i,ints:vi,float:Ni},Ei=new Map([...Ti,...Ni]),wi=(e,t)=>Ei.has(e)?Ei.get(e):!0===e.isNode?e:new ei(e,t),Ai=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every((e=>"object"!=typeof e)))&&(r=[Cs(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Pi(t.get(r[0]));if(1===r.length){const t=wi(r[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Pi(t):Pi(new Ws(t,e))}const s=r.map((e=>wi(e)));return Pi(new qs(s,e))}},Ri=e=>"object"==typeof e&&null!==e?e.value:e,Ci=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Mi(e,t){return new Proxy(new mi(e,t),oi)}const Pi=(e,t=null)=>function(e,t=null){const r=Rs(e);if("node"===r){let t=ui.get(e);return void 0===t&&(t=new Proxy(e,oi),ui.set(e,t),ui.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Pi(wi(e,t)):"shader"===r?Vi(e):e}(e,t),Li=(e,t=null)=>new di(e,t),Fi=(e,t=null)=>new ci(e,t),Bi=(...e)=>new hi(...e),Ii=(...e)=>new pi(...e);let Di=0;const Vi=(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 Mi(e,r),i=(...e)=>{let t;return Li(e),t=e[0]&&e[0].isNode?[...e]:e[0],s.call(t)};if(i.shaderNode=s,i.setLayout=e=>(s.setLayout(e),i),i.once=()=>(s.once=!0,i),null!==t){if("object"!=typeof t.inputs){const e={name:"fn"+Di++,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};ii("toGlobal",(e=>(e.global=!0,e)));const Ui=e=>{ri=e},Oi=()=>ri,Gi=(...e)=>ri.If(...e);function ki(e){return ri&&ri.add(e),e}ii("append",ki);const zi=new Ai("color"),$i=new Ai("float",Si.float),Hi=new Ai("int",Si.ints),Wi=new Ai("uint",Si.uint),ji=new Ai("bool",Si.bool),qi=new Ai("vec2"),Xi=new Ai("ivec2"),Ki=new Ai("uvec2"),Yi=new Ai("bvec2"),Qi=new Ai("vec3"),Zi=new Ai("ivec3"),Ji=new Ai("uvec3"),en=new Ai("bvec3"),tn=new Ai("vec4"),rn=new Ai("ivec4"),sn=new Ai("uvec4"),nn=new Ai("bvec4"),an=new Ai("mat2"),on=new Ai("mat3"),un=new Ai("mat4");ii("toColor",zi),ii("toFloat",$i),ii("toInt",Hi),ii("toUint",Wi),ii("toBool",ji),ii("toVec2",qi),ii("toIVec2",Xi),ii("toUVec2",Ki),ii("toBVec2",Yi),ii("toVec3",Qi),ii("toIVec3",Zi),ii("toUVec3",Ji),ii("toBVec3",en),ii("toVec4",tn),ii("toIVec4",rn),ii("toUVec4",sn),ii("toBVec4",nn),ii("toMat2",an),ii("toMat3",on),ii("toMat4",un);const ln=Bi(Hs).setParameterLength(2),dn=(e,t)=>Pi(new Ws(Pi(e),t));ii("element",ln),ii("convert",dn);class cn extends js{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}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 hn=(...e)=>{let t;if(1===e.length){const r=e[0];t=new cn(null,r.length,r)}else{const r=e[0],s=e[1];t=new cn(r,s)}return Pi(t)};ii("toArray",((e,t)=>hn(Array(t).fill(e))));class pn extends $s{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 gn=e=>new pn(e),mn=(e,t=0)=>new pn(e,!0,t),fn=mn("frame"),yn=mn("render"),xn=gn("object");class bn extends Zs{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=xn}label(e){return this.name=e,this}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)}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.label),o=e.getPropertyName(a);return void 0!==e.context.label&&delete e.context.label,e.format(o,r,t)}}const Tn=(e,t)=>{const r=Ci(t||e),s=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Pi(new bn(s,r))};class _n extends $s{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}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 vn=(e,t)=>Pi(new _n(e,t)),Nn=(e,t)=>Pi(new _n(e,t,!0)),Sn=Ii(_n,"vec4","DiffuseColor"),En=Ii(_n,"vec3","EmissiveColor"),wn=Ii(_n,"float","Roughness"),An=Ii(_n,"float","Metalness"),Rn=Ii(_n,"float","Clearcoat"),Cn=Ii(_n,"float","ClearcoatRoughness"),Mn=Ii(_n,"vec3","Sheen"),Pn=Ii(_n,"float","SheenRoughness"),Ln=Ii(_n,"float","Iridescence"),Fn=Ii(_n,"float","IridescenceIOR"),Bn=Ii(_n,"float","IridescenceThickness"),In=Ii(_n,"float","AlphaT"),Dn=Ii(_n,"float","Anisotropy"),Vn=Ii(_n,"vec3","AnisotropyT"),Un=Ii(_n,"vec3","AnisotropyB"),On=Ii(_n,"color","SpecularColor"),Gn=Ii(_n,"float","SpecularF90"),kn=Ii(_n,"float","Shininess"),zn=Ii(_n,"vec4","Output"),$n=Ii(_n,"float","dashSize"),Hn=Ii(_n,"float","gapSize"),Wn=Ii(_n,"float","pointWidth"),jn=Ii(_n,"float","IOR"),qn=Ii(_n,"float","Transmission"),Xn=Ii(_n,"float","Thickness"),Kn=Ii(_n,"float","AttenuationDistance"),Yn=Ii(_n,"color","AttenuationColor"),Qn=Ii(_n,"float","Dispersion");class Zn extends js{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}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 ks.join("").slice(0,r)!==t.components}return!1}generate(e,t){const{targetNode:r,sourceNode:s}=this,i=this.needsSplitAssign(e),n=r.getNodeType(e),a=r.context({assign:!0}).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.context({assign:!0}).build(e);for(let t=0;t<r.components.length;t++){const s=r.components[t];e.addLineFlowCode(`${u}.${s} = ${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 Jn=Bi(Zn).setParameterLength(2);ii("assign",Jn);class ea extends js{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($i(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($i(0),e)))}return`${r.build(e,"property")}( ${t.join(", ")} )`}}const ta=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?Fi(t):Li(t[0]),Pi(new ea(Pi(e),t)));ii("call",ta);class ra extends js{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new ra(e,t,r);for(let t=0;t<s.length-1;t++)i=new ra(e,i,s[t]);t=i,r=s[s.length-1]}this.op=e,this.aNode=t,this.bNode=r,this.isOperatorNode=!0}getNodeType(e,t){const r=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(e),a=void 0!==i?i.getNodeType(e):null;if("void"===n||"void"===a)return"void";if("%"===r)return n;if("~"===r||"&"===r||"|"===r||"^"===r||">>"===r||"<<"===r)return e.getIntegerType(n);if("!"===r||"=="===r||"!="===r||"&&"===r||"||"===r||"^^"===r)return"bool";if("<"===r||">"===r||"<="===r||">="===r){const r=t?e.getTypeLength(t):Math.max(e.getTypeLength(n),e.getTypeLength(a));return r>1?`bvec${r}`:"bool"}if(e.isMatrix(n)){if("float"===a)return n;if(e.isVector(a))return e.getVectorFromMatrix(n);if(e.isMatrix(a))return n}else if(e.isMatrix(a)){if("float"===n)return a;if(e.isVector(n))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(n)?a:n}generate(e,t){const r=this.op,s=this.aNode,i=this.bNode,n=this.getNodeType(e,t);let a=null,o=null;"void"!==n?(a=s.getNodeType(e),o=void 0!==i?i.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a: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=void 0!==i?i.build(e,o):null,c=e.getTypeLength(t),h=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===l;if("=="===r)return s?c>1?e.format(`${e.getMethod("equal",t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} ${r} ${d} )`,n,t):c>1||!e.isVector(a)?e.format(`( ${u} == ${d} )`,n,t):e.format(`all( ${u} == ${d} )`,n,t);if("<"===r&&c>1)return s?e.format(`${e.getMethod("lessThan",t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} < ${d} )`,n,t);if("<="===r&&c>1)return s?e.format(`${e.getMethod("lessThanEqual",t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} <= ${d} )`,n,t);if(">"===r&&c>1)return s?e.format(`${e.getMethod("greaterThan",t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} > ${d} )`,n,t);if(">="===r&&c>1)return s?e.format(`${e.getMethod("greaterThanEqual",t)}( ${u}, ${d} )`,n,t):e.format(`( ${u} >= ${d} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${d} )`,n,t):e.format(`${e.getMethod("mod",n)}( ${u}, ${d} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(h)return e.format(`${h}( ${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 h?e.format(`${h}( ${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 sa=Bi(ra,"+").setParameterLength(2,1/0).setName("add"),ia=Bi(ra,"-").setParameterLength(2,1/0).setName("sub"),na=Bi(ra,"*").setParameterLength(2,1/0).setName("mul"),aa=Bi(ra,"/").setParameterLength(2,1/0).setName("div"),oa=Bi(ra,"%").setParameterLength(2).setName("mod"),ua=Bi(ra,"==").setParameterLength(2).setName("equal"),la=Bi(ra,"!=").setParameterLength(2).setName("notEqual"),da=Bi(ra,"<").setParameterLength(2).setName("lessThan"),ca=Bi(ra,">").setParameterLength(2).setName("greaterThan"),ha=Bi(ra,"<=").setParameterLength(2).setName("lessThanEqual"),pa=Bi(ra,">=").setParameterLength(2).setName("greaterThanEqual"),ga=Bi(ra,"&&").setParameterLength(2,1/0).setName("and"),ma=Bi(ra,"||").setParameterLength(2,1/0).setName("or"),fa=Bi(ra,"!").setParameterLength(1).setName("not"),ya=Bi(ra,"^^").setParameterLength(2).setName("xor"),xa=Bi(ra,"&").setParameterLength(2).setName("bitAnd"),ba=Bi(ra,"~").setParameterLength(2).setName("bitNot"),Ta=Bi(ra,"|").setParameterLength(2).setName("bitOr"),_a=Bi(ra,"^").setParameterLength(2).setName("bitXor"),va=Bi(ra,"<<").setParameterLength(2).setName("shiftLeft"),Na=Bi(ra,">>").setParameterLength(2).setName("shiftRight");ii("add",sa),ii("sub",ia),ii("mul",na),ii("div",aa),ii("mod",oa),ii("equal",ua),ii("notEqual",la),ii("lessThan",da),ii("greaterThan",ca),ii("lessThanEqual",ha),ii("greaterThanEqual",pa),ii("and",ga),ii("or",ma),ii("not",fa),ii("xor",ya),ii("bitAnd",xa),ii("bitNot",ba),ii("bitOr",Ta),ii("bitXor",_a),ii("shiftLeft",va),ii("shiftRight",Na);const Sa=(e,t)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),oa(e,t)),Ea=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),oa(Hi(e),Hi(t)));ii("remainder",Sa),ii("modInt",Ea);class wa extends js{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===wa.MAX||e===wa.MIN)&&arguments.length>3){let i=new wa(e,t,r);for(let t=2;t<arguments.length-1;t++)i=new wa(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===wa.LENGTH||t===wa.DISTANCE||t===wa.DOT?"float":t===wa.CROSS?"vec3":t===wa.ALL||t===wa.ANY?"bool":t===wa.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}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===wa.TRANSFORM_DIRECTION){let r=n,s=a;e.isMatrix(r.getNodeType(e))?s=tn(Qi(s),0):r=tn(Qi(r),0);const i=na(r,s).xyz;return $a(i).build(e,t)}if(r===wa.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);if(r===wa.ONE_MINUS)return ia(1,n).build(e,t);if(r===wa.RECIPROCAL)return aa(1,n).build(e,t);if(r===wa.DIFFERENCE)return Qa(ia(n,a)).build(e,t);{const c=[];return r===wa.CROSS?c.push(n.build(e,s),a.build(e,s)):u===l&&r===wa.STEP?c.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":i),a.build(e,i)):u!==l||r!==wa.MIN&&r!==wa.MAX?r===wa.REFRACT?c.push(n.build(e,i),a.build(e,i),o.build(e,"float")):r===wa.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===wa.ATAN&&null!==a&&(r="atan2"),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}}wa.ALL="all",wa.ANY="any",wa.RADIANS="radians",wa.DEGREES="degrees",wa.EXP="exp",wa.EXP2="exp2",wa.LOG="log",wa.LOG2="log2",wa.SQRT="sqrt",wa.INVERSE_SQRT="inversesqrt",wa.FLOOR="floor",wa.CEIL="ceil",wa.NORMALIZE="normalize",wa.FRACT="fract",wa.SIN="sin",wa.COS="cos",wa.TAN="tan",wa.ASIN="asin",wa.ACOS="acos",wa.ATAN="atan",wa.ABS="abs",wa.SIGN="sign",wa.LENGTH="length",wa.NEGATE="negate",wa.ONE_MINUS="oneMinus",wa.DFDX="dFdx",wa.DFDY="dFdy",wa.ROUND="round",wa.RECIPROCAL="reciprocal",wa.TRUNC="trunc",wa.FWIDTH="fwidth",wa.TRANSPOSE="transpose",wa.BITCAST="bitcast",wa.EQUALS="equals",wa.MIN="min",wa.MAX="max",wa.STEP="step",wa.REFLECT="reflect",wa.DISTANCE="distance",wa.DIFFERENCE="difference",wa.DOT="dot",wa.CROSS="cross",wa.POW="pow",wa.TRANSFORM_DIRECTION="transformDirection",wa.MIX="mix",wa.CLAMP="clamp",wa.REFRACT="refract",wa.SMOOTHSTEP="smoothstep",wa.FACEFORWARD="faceforward";const Aa=$i(1e-6),Ra=$i(1e6),Ca=$i(Math.PI),Ma=$i(2*Math.PI),Pa=Bi(wa,wa.ALL).setParameterLength(1),La=Bi(wa,wa.ANY).setParameterLength(1),Fa=Bi(wa,wa.RADIANS).setParameterLength(1),Ba=Bi(wa,wa.DEGREES).setParameterLength(1),Ia=Bi(wa,wa.EXP).setParameterLength(1),Da=Bi(wa,wa.EXP2).setParameterLength(1),Va=Bi(wa,wa.LOG).setParameterLength(1),Ua=Bi(wa,wa.LOG2).setParameterLength(1),Oa=Bi(wa,wa.SQRT).setParameterLength(1),Ga=Bi(wa,wa.INVERSE_SQRT).setParameterLength(1),ka=Bi(wa,wa.FLOOR).setParameterLength(1),za=Bi(wa,wa.CEIL).setParameterLength(1),$a=Bi(wa,wa.NORMALIZE).setParameterLength(1),Ha=Bi(wa,wa.FRACT).setParameterLength(1),Wa=Bi(wa,wa.SIN).setParameterLength(1),ja=Bi(wa,wa.COS).setParameterLength(1),qa=Bi(wa,wa.TAN).setParameterLength(1),Xa=Bi(wa,wa.ASIN).setParameterLength(1),Ka=Bi(wa,wa.ACOS).setParameterLength(1),Ya=Bi(wa,wa.ATAN).setParameterLength(1,2),Qa=Bi(wa,wa.ABS).setParameterLength(1),Za=Bi(wa,wa.SIGN).setParameterLength(1),Ja=Bi(wa,wa.LENGTH).setParameterLength(1),eo=Bi(wa,wa.NEGATE).setParameterLength(1),to=Bi(wa,wa.ONE_MINUS).setParameterLength(1),ro=Bi(wa,wa.DFDX).setParameterLength(1),so=Bi(wa,wa.DFDY).setParameterLength(1),io=Bi(wa,wa.ROUND).setParameterLength(1),no=Bi(wa,wa.RECIPROCAL).setParameterLength(1),ao=Bi(wa,wa.TRUNC).setParameterLength(1),oo=Bi(wa,wa.FWIDTH).setParameterLength(1),uo=Bi(wa,wa.TRANSPOSE).setParameterLength(1),lo=Bi(wa,wa.BITCAST).setParameterLength(2),co=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ua(e,t)),ho=Bi(wa,wa.MIN).setParameterLength(2,1/0),po=Bi(wa,wa.MAX).setParameterLength(2,1/0),go=Bi(wa,wa.STEP).setParameterLength(2),mo=Bi(wa,wa.REFLECT).setParameterLength(2),fo=Bi(wa,wa.DISTANCE).setParameterLength(2),yo=Bi(wa,wa.DIFFERENCE).setParameterLength(2),xo=Bi(wa,wa.DOT).setParameterLength(2),bo=Bi(wa,wa.CROSS).setParameterLength(2),To=Bi(wa,wa.POW).setParameterLength(2),_o=Bi(wa,wa.POW,2).setParameterLength(1),vo=Bi(wa,wa.POW,3).setParameterLength(1),No=Bi(wa,wa.POW,4).setParameterLength(1),So=Bi(wa,wa.TRANSFORM_DIRECTION).setParameterLength(2),Eo=e=>na(Za(e),To(Qa(e),1/3)),wo=e=>xo(e,e),Ao=Bi(wa,wa.MIX).setParameterLength(3),Ro=(e,t=0,r=1)=>Pi(new wa(wa.CLAMP,Pi(e),Pi(t),Pi(r))),Co=e=>Ro(e),Mo=Bi(wa,wa.REFRACT).setParameterLength(3),Po=Bi(wa,wa.SMOOTHSTEP).setParameterLength(3),Lo=Bi(wa,wa.FACEFORWARD).setParameterLength(3),Fo=Vi((([e])=>{const t=xo(e.xy,qi(12.9898,78.233)),r=oa(t,Ca);return Ha(Wa(r).mul(43758.5453))})),Bo=(e,t,r)=>Ao(t,r,e),Io=(e,t,r)=>Po(t,r,e),Do=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),Ya(e,t)),Vo=Lo,Uo=Ga;ii("all",Pa),ii("any",La),ii("equals",co),ii("radians",Fa),ii("degrees",Ba),ii("exp",Ia),ii("exp2",Da),ii("log",Va),ii("log2",Ua),ii("sqrt",Oa),ii("inverseSqrt",Ga),ii("floor",ka),ii("ceil",za),ii("normalize",$a),ii("fract",Ha),ii("sin",Wa),ii("cos",ja),ii("tan",qa),ii("asin",Xa),ii("acos",Ka),ii("atan",Ya),ii("abs",Qa),ii("sign",Za),ii("length",Ja),ii("lengthSq",wo),ii("negate",eo),ii("oneMinus",to),ii("dFdx",ro),ii("dFdy",so),ii("round",io),ii("reciprocal",no),ii("trunc",ao),ii("fwidth",oo),ii("atan2",Do),ii("min",ho),ii("max",po),ii("step",go),ii("reflect",mo),ii("distance",fo),ii("dot",xo),ii("cross",bo),ii("pow",To),ii("pow2",_o),ii("pow3",vo),ii("pow4",No),ii("transformDirection",So),ii("mix",Bo),ii("clamp",Ro),ii("refract",Mo),ii("smoothstep",Io),ii("faceForward",Lo),ii("difference",yo),ii("saturate",Co),ii("cbrt",Eo),ii("transpose",uo),ii("rand",Fo);class Oo extends $s{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return this.setup(e),this.getNodeType(e);const s=t.getNodeType(e);if(null!==r){const t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(s))return t}return s}setup(e){const t=this.condNode.cache(),r=this.ifNode.cache(),s=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=i,null!==s&&(e.getDataFromNode(s).parentNodeBlock=i);const n=e.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=s?s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(void 0!==s.nodeProperty)return s.nodeProperty;const{condNode:i,ifNode:n,elseNode:a}=