three
Version:
JavaScript 3D library
6 lines • 616 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,error as o,EventDispatcher as u,MathUtils as l,warn as d,WebGLCoordinateSystem as c,WebGPUCoordinateSystem as h,ColorManagement as p,SRGBTransfer as g,NoToneMapping as m,StaticDrawUsage as f,InterleavedBufferAttribute as y,InterleavedBuffer as b,DynamicDrawUsage as x,NoColorSpace as T,log as _,warnOnce as v,Texture as N,UnsignedIntType as S,IntType as R,NearestFilter as A,Sphere as E,BackSide as w,DoubleSide as C,Euler as M,CubeTexture as B,CubeReflectionMapping as L,CubeRefractionMapping as F,TangentSpaceNormalMap as P,NoNormalPacking as D,NormalRGPacking as U,NormalGAPacking as I,ObjectSpaceNormalMap as O,RGFormat as V,RED_GREEN_RGTC2_Format as k,RG11_EAC_Format as G,InstancedInterleavedBuffer as z,InstancedBufferAttribute as $,DataArrayTexture as W,FloatType as H,FramebufferTexture as q,LinearMipmapLinearFilter as j,DepthTexture as X,Material as K,LineBasicMaterial as Y,LineDashedMaterial as Q,NoBlending as Z,MeshNormalMaterial as J,SRGBColorSpace as ee,WebGLCubeRenderTarget as te,BoxGeometry as re,Mesh as se,Scene as ie,LinearFilter as ne,CubeCamera as ae,EquirectangularReflectionMapping as oe,EquirectangularRefractionMapping as ue,AddOperation as le,MixOperation as de,MultiplyOperation as ce,MeshBasicMaterial as he,MeshLambertMaterial as pe,MeshPhongMaterial as ge,DataTexture as me,HalfFloatType as fe,ClampToEdgeWrapping as ye,BufferGeometry as be,OrthographicCamera as xe,PerspectiveCamera as Te,RenderTarget as _e,LinearSRGBColorSpace as ve,RGBAFormat as Ne,CubeUVReflectionMapping as Se,BufferAttribute as Re,MeshStandardMaterial as Ae,MeshPhysicalMaterial as Ee,MeshToonMaterial as we,MeshMatcapMaterial as Ce,SpriteMaterial as Me,PointsMaterial as Be,ShadowMaterial as Le,Uint32BufferAttribute as Fe,Uint16BufferAttribute as Pe,arrayNeedsUint32 as De,Camera as Ue,DepthStencilFormat as Ie,DepthFormat as Oe,UnsignedInt248Type as Ve,UnsignedByteType as ke,Plane as Ge,Object3D as ze,LinearMipMapLinearFilter as $e,Float32BufferAttribute as We,UVMapping as He,VSMShadowMap as qe,LessCompare as je,BasicShadowMap as Xe,CubeDepthTexture as Ke,SphereGeometry as Ye,NormalBlending as Qe,LinearMipmapNearestFilter as Ze,NearestMipmapLinearFilter as Je,Float16BufferAttribute as et,REVISION as tt,ArrayCamera as rt,PlaneGeometry as st,FrontSide as it,CustomBlending as nt,AddEquation as at,ZeroFactor as ot,CylinderGeometry as ut,Quaternion as lt,WebXRController as dt,RAD2DEG as ct,PCFShadowMap as ht,FrustumArray as pt,Frustum as gt,RedIntegerFormat as mt,RedFormat as ft,ShortType as yt,ByteType as bt,UnsignedShortType as xt,RGIntegerFormat as Tt,RGBIntegerFormat as _t,RGBFormat as vt,RGBAIntegerFormat as Nt,TimestampQuery as St,createCanvasElement as Rt,ReverseSubtractEquation as At,SubtractEquation as Et,OneMinusDstAlphaFactor as wt,OneMinusDstColorFactor as Ct,OneMinusSrcAlphaFactor as Mt,OneMinusSrcColorFactor as Bt,DstAlphaFactor as Lt,DstColorFactor as Ft,SrcAlphaSaturateFactor as Pt,SrcAlphaFactor as Dt,SrcColorFactor as Ut,OneFactor as It,CullFaceNone as Ot,CullFaceBack as Vt,CullFaceFront as kt,MultiplyBlending as Gt,SubtractiveBlending as zt,AdditiveBlending as $t,NotEqualDepth as Wt,GreaterDepth as Ht,GreaterEqualDepth as qt,EqualDepth as jt,LessEqualDepth as Xt,LessDepth as Kt,AlwaysDepth as Yt,NeverDepth as Qt,UnsignedShort4444Type as Zt,UnsignedShort5551Type as Jt,UnsignedInt5999Type as er,UnsignedInt101111Type as tr,AlphaFormat as rr,RGB_S3TC_DXT1_Format as sr,RGBA_S3TC_DXT1_Format as ir,RGBA_S3TC_DXT3_Format as nr,RGBA_S3TC_DXT5_Format as ar,RGB_PVRTC_4BPPV1_Format as or,RGB_PVRTC_2BPPV1_Format as ur,RGBA_PVRTC_4BPPV1_Format as lr,RGBA_PVRTC_2BPPV1_Format as dr,RGB_ETC1_Format as cr,RGB_ETC2_Format as hr,RGBA_ETC2_EAC_Format as pr,R11_EAC_Format as gr,SIGNED_R11_EAC_Format as mr,SIGNED_RG11_EAC_Format as fr,RGBA_ASTC_4x4_Format as yr,RGBA_ASTC_5x4_Format as br,RGBA_ASTC_5x5_Format as xr,RGBA_ASTC_6x5_Format as Tr,RGBA_ASTC_6x6_Format as _r,RGBA_ASTC_8x5_Format as vr,RGBA_ASTC_8x6_Format as Nr,RGBA_ASTC_8x8_Format as Sr,RGBA_ASTC_10x5_Format as Rr,RGBA_ASTC_10x6_Format as Ar,RGBA_ASTC_10x8_Format as Er,RGBA_ASTC_10x10_Format as wr,RGBA_ASTC_12x10_Format as Cr,RGBA_ASTC_12x12_Format as Mr,RGBA_BPTC_Format as Br,RED_RGTC1_Format as Lr,SIGNED_RED_RGTC1_Format as Fr,SIGNED_RED_GREEN_RGTC2_Format as Pr,MirroredRepeatWrapping as Dr,RepeatWrapping as Ur,NearestMipmapNearestFilter as Ir,NotEqualCompare as Or,GreaterCompare as Vr,GreaterEqualCompare as kr,EqualCompare as Gr,LessEqualCompare as zr,AlwaysCompare as $r,NeverCompare as Wr,LinearTransfer as Hr,getByteLength as qr,isTypedArray as jr,NotEqualStencilFunc as Xr,GreaterStencilFunc as Kr,GreaterEqualStencilFunc as Yr,EqualStencilFunc as Qr,LessEqualStencilFunc as Zr,LessStencilFunc as Jr,AlwaysStencilFunc as es,NeverStencilFunc as ts,DecrementWrapStencilOp as rs,IncrementWrapStencilOp as ss,DecrementStencilOp as is,IncrementStencilOp as ns,InvertStencilOp as as,ReplaceStencilOp as os,ZeroStencilOp as us,KeepStencilOp as ls,MaxEquation as ds,MinEquation as cs,SpotLight as hs,PointLight as ps,DirectionalLight as gs,RectAreaLight as ms,AmbientLight as fs,HemisphereLight as ys,LightProbe as bs,LinearToneMapping as xs,ReinhardToneMapping as Ts,CineonToneMapping as _s,ACESFilmicToneMapping as vs,AgXToneMapping as Ns,NeutralToneMapping as Ss,Group as Rs,Loader as As,FileLoader as Es,MaterialLoader as ws,ObjectLoader as Cs}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,ExternalTexture,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,TorusGeometry,TorusKnotGeometry,Triangle,TriangleFanDrawMode,TriangleStripDrawMode,TrianglesDrawMode,TubeGeometry,Uint8BufferAttribute,Uint8ClampedBufferAttribute,Uniform,UniformsGroup,VectorKeyframeTrack,VideoFrameTexture,VideoTexture,WebGL3DRenderTarget,WebGLArrayRenderTarget,WebGLRenderTarget,WireframeGeometry,WrapAroundEnding,ZeroCurvatureEnding,ZeroSlopeEnding,getConsoleFunction,setConsoleFunction}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"],Bs=new WeakMap;class Ls{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!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}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]&&(n.morphTargetInfluences[t]=r.morphTargetInfluences[t],e=!0);if(e)return!1}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(Bs.has(e)){const r=Bs.get(e);if(r.renderId===t)return r.lightsData}const r=this.getLightsData(e.getLights());return Bs.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 Fs(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 Ps=e=>Fs(e),Ds=e=>Fs(e),Us=(...e)=>Fs(e),Is=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Os=new WeakMap;function Vs(e){return Is.get(e)}function ks(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 Gs(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 o("TSL: Unsupported type:",e)}function zs(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 o("TSL: Unsupported type:",e)}function $s(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)||/mat4/.test(e)?16:void o("TSL: Unsupported type:",e)}function Ws(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 Hs(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?Xs(u[0]):null}function qs(e){let t=Os.get(e);return void 0===t&&(t={},Os.set(e,t)),t}function js(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 Xs(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Ks=Object.freeze({__proto__:null,arrayBufferToBase64:js,base64ToArrayBuffer:Xs,getAlignmentFromType:$s,getDataFromObject:qs,getLengthFromType:Gs,getMemoryLengthFromType:zs,getTypeFromLength:Vs,getTypedArrayFromType:ks,getValueFromType:Hs,getValueType:Ws,hash:Us,hashArray:Ds,hashString:Ps});const Ys={VERTEX:"vertex",FRAGMENT:"fragment"},Qs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Zs={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Js={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},ei=["fragment","vertex"],ti=["setup","analyze","generate"],ri=[...ei,"compute"],si=["x","y","z","w"],ii={analyze:"setup",generate:"analyze"};let ni=0;class ai extends u{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Qs.NONE,this.updateBeforeType=Qs.NONE,this.updateAfterType=Qs.NONE,this.uuid=l.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:ni++})}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),this}onFrameUpdate(e){return this.onUpdate(e,Qs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Qs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Qs.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const r of Object.getOwnPropertyNames(this)){const s=this[r];if(!0!==r.startsWith("_")&&!e.has(s))if(!0===Array.isArray(s))for(let e=0;e<s.length;e++){const i=s[e];i&&!0===i.isNode&&t.push({property:r,index:e,childNode:i})}else if(s&&!0===s.isNode)t.push({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.push({property:r,index:e,childNode:i})}}return t}getCacheKey(e=!1,t=null){if(!0===(e=e||this.version!==this._cacheKeyVersion)||null===this._cacheKey){null===t&&(t=new Set);const r=[];for(const{property:s,childNode:i}of this._getChildren(t))r.push(Ps(s.slice(0,-4)),i.getCacheKey(e,t));this._cacheKey=Us(Ds(r),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}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(){d("Abstract function.")}updateAfter(){d("Abstract function.")}update(){d("Abstract function.")}before(e){return null===this._beforeNodes&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);if(null!==this._beforeNodes){const r=this._beforeNodes;this._beforeNodes=null;for(const s of r)s.build(e,t);this._beforeNodes=r}const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const i=ii[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(this.generate.length<2){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):(d("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)||"";""===n&&null!==t&&"void"!==t&&"OutputType"!==t&&(o(`TSL: Invalid generated code, expected a "${t}".`),n=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return this._getChildren()}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 oi extends ai{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)}getMemberType(e,t){return this.node.getMemberType(e,t)}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 ui extends ai{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 li extends ai{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 di extends li{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 u=0;for(const t of i){if(u>=s){o(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let i,l=t.getNodeType(e),d=e.getTypeLength(l);u+d>s&&(o(`TSL: Length of '${r}()' data exceeds maximum length of output type.`),d=s-u,l=e.getTypeFromLength(d)),u+=d,i=t.build(e,l);if(e.getComponentType(l)!==n){const t=e.getTypeFromLength(d,n);i=e.format(i,l,t)}a.push(i)}const l=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(l,r,t)}}const ci=si.join("");class hi extends ai{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(si.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))}getScope(){return this.node.getScope()}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===ci.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 pi extends li{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=si[e];t===r[0]?(d.push(o),e+=r.length-1):d.push(u+"."+t)}return`${e.getType(i)}( ${d.join(", ")} )`}}class gi extends li{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=si[e];r===t[l]?(u.push("1.0 - "+a+"."+r),l++):u.push(a+"."+r)}return`${e.getType(s)}( ${u.join(", ")} )`}}class mi extends ai{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?Ws(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=Ws(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=js(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Hs(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){d("Abstract function.")}}const fi=/float|u?int/;class yi extends mi{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 fi.test(r)&&fi.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class bi extends ai{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return(!this.structNode.isMemberNode||!1!==this.structNode.hasMember(e))&&"void"!==this.structNode.getMemberType(e,this.property)}getNodeType(e){return!1===this.hasMember(e)?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(!1===this.hasMember(e))return"float";const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}generate(e){if(!1===this.hasMember(e)){d(`TSL: Member "${this.property}" does not exist in struct.`);const t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}}let xi=null;const Ti=new Map;function _i(e,t){if(Ti.has(e))d(`TSL: Redefinition of method chaining '${e}'.`);else{if("function"!=typeof t)throw new Error(`THREE.TSL: Node element ${e} is not a function`);Ti.set(e,t),"assign"!==e&&(ai.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},ai.prototype[e+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}}const vi=e=>(e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"))(e).split("").sort().join("");ai.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==xi?xi.assign(this,...e):o("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const t=Ti.get("assign");return this.addToStack(t(...e))}},ai.prototype.toVarIntent=function(){return this},ai.prototype.get=function(e){return new bi(this,e)};const Ni={};function Si(e,t,r){Ni[e]=Ni[t]=Ni[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new hi(this,e),this._cache[e]=t),t},set(t){this[e].assign(Yi(t))}};const s=e.toUpperCase(),i=t.toUpperCase(),n=r.toUpperCase();ai.prototype["set"+s]=ai.prototype["set"+i]=ai.prototype["set"+n]=function(t){const r=vi(e);return new pi(this,r,Yi(t))},ai.prototype["flip"+s]=ai.prototype["flip"+i]=ai.prototype["flip"+n]=function(){const t=vi(e);return new gi(this,t)}}const Ri=["x","y","z","w"],Ai=["r","g","b","a"],Ei=["s","t","p","q"];for(let e=0;e<4;e++){let t=Ri[e],r=Ai[e],s=Ei[e];Si(t,r,s);for(let i=0;i<4;i++){t=Ri[e]+Ri[i],r=Ai[e]+Ai[i],s=Ei[e]+Ei[i],Si(t,r,s);for(let n=0;n<4;n++){t=Ri[e]+Ri[i]+Ri[n],r=Ai[e]+Ai[i]+Ai[n],s=Ei[e]+Ei[i]+Ei[n],Si(t,r,s);for(let a=0;a<4;a++)t=Ri[e]+Ri[i]+Ri[n]+Ri[a],r=Ai[e]+Ai[i]+Ai[n]+Ai[a],s=Ei[e]+Ei[i]+Ei[n]+Ei[a],Si(t,r,s)}}}for(let e=0;e<32;e++)Ni[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new oi(this,new yi(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(Yi(t))}};Object.defineProperties(ai.prototype,Ni);const wi=new WeakMap,Ci=function(e,t=null){for(const r in e)e[r]=Yi(e[r],t);return e},Mi=function(e,t=null){const r=e.length;for(let s=0;s<r;s++)e[s]=Yi(e[s],t);return e},Bi=function(e,t=null,r=null,s=null){function i(e){return null!==s?(e=Yi(Object.assign(e,s)),!0===s.intent&&(e=e.toVarIntent())):e=Yi(e),e}let n,a,u,l=t;function d(t){let r;return r=l?/[a-z]/i.test(l)?l+"()":l:e.type,void 0!==a&&t.length<a?(o(`TSL: "${r}" parameter length is less than minimum required.`),t.concat(new Array(a-t.length).fill(0))):void 0!==u&&t.length>u?(o(`TSL: "${r}" parameter length exceeds limit.`),t.slice(0,u)):t}return null===t?n=(...t)=>i(new e(...Ji(d(t)))):null!==r?(r=Yi(r),n=(...s)=>i(new e(t,...Ji(d(s)),r))):n=(...r)=>i(new e(t,...Ji(d(r)))),n.setParameterLength=(...e)=>(1===e.length?a=u=e[0]:2===e.length&&([a,u]=e),n),n.setName=e=>(l=e,n),n},Li=function(e,...t){return new e(...Ji(t))};class Fi extends ai{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:r}=this,s=e.getNodeProperties(t),i=e.getClosestSubBuild(t.subBuilds)||"",n=i||"default";if(s[n])return s[n];const a=e.subBuildFn,o=e.fnCall;e.subBuildFn=i,e.fnCall=this;let u=null;if(t.layout){let s=wi.get(e.constructor);void 0===s&&(s=new WeakMap,wi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=Yi(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i);const n=r?function(e){let t;Zi(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];return t}(r):null;u=Yi(i.call(n))}else{const s=new Proxy(e,{get:(e,t,r)=>{let s;return s=Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r),s}}),i=r?function(e){let t=0;return Zi(e),new Proxy(e,{get:(r,s,i)=>{let n;if("length"===s)return n=e.length,n;if(Symbol.iterator===s)n=function*(){for(const t of e)yield Yi(t)};else{if(e.length>0)if(Object.getPrototypeOf(e[0])===Object.prototype){const r=e[0];n=void 0===r[s]?r[t++]:Reflect.get(r,s,i)}else e[0]instanceof ai&&(n=void 0===e[s]?e[t++]:Reflect.get(e,s,i));else n=Reflect.get(r,s,i);n=Yi(n)}return n}})}(r):null,n=Array.isArray(r)?r.length>0:null!==r,a=t.jsFunc,o=n||a.length>1?a(i,s):a(s);u=Yi(o)}return e.subBuildFn=a,e.fnCall=o,t.once&&(s[n]=u),u}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),o=e.fnCall;if(e.fnCall=this,"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 e.fnCall=o,r}}class Pi extends ai{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new Fi(this,e)}setup(){return this.call()}}const Di=[!1,!0],Ui=[0,1,2,3],Ii=[-1,-2],Oi=[.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],Vi=new Map;for(const e of Di)Vi.set(e,new yi(e));const ki=new Map;for(const e of Ui)ki.set(e,new yi(e,"uint"));const Gi=new Map([...ki].map(e=>new yi(e.value,"int")));for(const e of Ii)Gi.set(e,new yi(e,"int"));const zi=new Map([...Gi].map(e=>new yi(e.value)));for(const e of Oi)zi.set(e,new yi(e));for(const e of Oi)zi.set(-e,new yi(-e));const $i={bool:Vi,uint:ki,ints:Gi,float:zi},Wi=new Map([...Vi,...zi]),Hi=(e,t)=>Wi.has(e)?Wi.get(e):!0===e.isNode?e:new yi(e,t),qi=function(e,t=null){return(...r)=>{for(const t of r)if(void 0===t)return o(`TSL: Invalid parameter for the type "${e}".`),new yi(0,e);if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every(e=>{const t=typeof e;return"object"!==t&&"function"!==t}))&&(r=[Hs(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return Qi(t.get(r[0]));if(1===r.length){const t=Hi(r[0],e);return t.nodeType===e?Qi(t):Qi(new ui(t,e))}const s=r.map(e=>Hi(e));return Qi(new di(s,e))}},ji=e=>"object"==typeof e&&null!==e?e.value:e,Xi=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Ki(e,t){return new Pi(e,t)}const Yi=(e,t=null)=>function(e,t=null){const r=Ws(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?Yi(Hi(e,t)):"shader"===r?e.isFn?e:an(e):e}(e,t),Qi=(e,t=null)=>Yi(e,t).toVarIntent(),Zi=(e,t=null)=>new Ci(e,t),Ji=(e,t=null)=>new Mi(e,t),en=(e,t=null,r=null,s=null)=>new Bi(e,t,r,s),tn=(e,...t)=>new Li(e,...t),rn=(e,t=null,r=null,s={})=>new Bi(e,t,r,{...s,intent:!0});let sn=0;class nn extends ai{constructor(e,t=null){super();let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:o("TSL: Invalid layout type."),t=null)),this.shaderNode=new Ki(e,r),null!==t&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if("object"!=typeof e.inputs){const r={name:"fn"+sn++,type:t,inputs:[]};for(const t in e)"return"!==t&&r.inputs.push({name:t,type:e[t]});e=r}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return"void"===this.shaderNode.nodeType&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return o('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function an(e,t=null){const r=new nn(e,t);return new Proxy(()=>{},{apply:(e,t,s)=>r.call(...s),get:(e,t,s)=>Reflect.get(r,t,s),set:(e,t,s,i)=>Reflect.set(r,t,s,i)})}const on=e=>{xi=e},un=()=>xi,ln=(...e)=>xi.If(...e);function dn(e){return xi&&xi.addToStack(e),e}_i("toStack",dn);const cn=new qi("color"),hn=new qi("float",$i.float),pn=new qi("int",$i.ints),gn=new qi("uint",$i.uint),mn=new qi("bool",$i.bool),fn=new qi("vec2"),yn=new qi("ivec2"),bn=new qi("uvec2"),xn=new qi("bvec2"),Tn=new qi("vec3"),_n=new qi("ivec3"),vn=new qi("uvec3"),Nn=new qi("bvec3"),Sn=new qi("vec4"),Rn=new qi("ivec4"),An=new qi("uvec4"),En=new qi("bvec4"),wn=new qi("mat2"),Cn=new qi("mat3"),Mn=new qi("mat4");_i("toColor",cn),_i("toFloat",hn),_i("toInt",pn),_i("toUint",gn),_i("toBool",mn),_i("toVec2",fn),_i("toIVec2",yn),_i("toUVec2",bn),_i("toBVec2",xn),_i("toVec3",Tn),_i("toIVec3",_n),_i("toUVec3",vn),_i("toBVec3",Nn),_i("toVec4",Sn),_i("toIVec4",Rn),_i("toUVec4",An),_i("toBVec4",En),_i("toMat2",wn),_i("toMat3",Cn),_i("toMat4",Mn);const Bn=en(oi).setParameterLength(2),Ln=(e,t)=>Yi(new ui(Yi(e),t));_i("element",Bn),_i("convert",Ln);_i("append",e=>(d("TSL: .append() has been renamed to .toStack()."),dn(e)));class Fn extends ai{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}customCacheKey(){return Ps(this.type+":"+(this.name||"")+":"+(this.varying?"1":"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 Pn=(e,t)=>new Fn(e,t),Dn=(e,t)=>new Fn(e,t,!0),Un=tn(Fn,"vec4","DiffuseColor"),In=tn(Fn,"vec3","DiffuseContribution"),On=tn(Fn,"vec3","EmissiveColor"),Vn=tn(Fn,"float","Roughness"),kn=tn(Fn,"float","Metalness"),Gn=tn(Fn,"float","Clearcoat"),zn=tn(Fn,"float","ClearcoatRoughness"),$n=tn(Fn,"vec3","Sheen"),Wn=tn(Fn,"float","SheenRoughness"),Hn=tn(Fn,"float","Iridescence"),qn=tn(Fn,"float","IridescenceIOR"),jn=tn(Fn,"float","IridescenceThickness"),Xn=tn(Fn,"float","AlphaT"),Kn=tn(Fn,"float","Anisotropy"),Yn=tn(Fn,"vec3","AnisotropyT"),Qn=tn(Fn,"vec3","AnisotropyB"),Zn=tn(Fn,"color","SpecularColor"),Jn=tn(Fn,"color","SpecularColorBlended"),ea=tn(Fn,"float","SpecularF90"),ta=tn(Fn,"float","Shininess"),ra=tn(Fn,"vec4","Output"),sa=tn(Fn,"float","dashSize"),ia=tn(Fn,"float","gapSize"),na=tn(Fn,"float","pointWidth"),aa=tn(Fn,"float","IOR"),oa=tn(Fn,"float","Transmission"),ua=tn(Fn,"float","Thickness"),la=tn(Fn,"float","AttenuationDistance"),da=tn(Fn,"color","AttenuationColor"),ca=tn(Fn,"float","Dispersion");class ha extends ai{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 pa=e=>new ha(e),ga=(e,t=0)=>new ha(e,!0,t),ma=ga("frame"),fa=ga("render"),ya=pa("object");class ba extends mi{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=ya}setName(e){return this.name=e,this}label(e){return d('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){return e=e.bind(this),super.onUpdate(t=>{const r=e(t,this);void 0!==r&&(this.value=r)},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 xa=(e,t)=>{const r=Xi(t||e);if(r===e&&(e=Hs(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new ba(e,r)};class Ta extends li{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.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return null===this.nodeType?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const _a=(...e)=>{let t;if(1===e.length){const r=e[0];t=new Ta(null,r.length,r)}else{const r=e[0],s=e[1];t=new Ta(r,s)}return Yi(t)};_i("toArray",(e,t)=>_a(Array(t).fill(e)));class va extends li{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 si.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=t.getScope();e.getDataFromNode(s).assign=!0;const i=e.getNodeProperties(this);i.sourceNode=r,i.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),i=this.needsSplitAssign(e),n=r.build(e),a=r.getNodeType(e),o=s.build(e,a),u=s.getNodeType(e),l=e.getDataFromNode(this);let d;if(!0===l.initialized)"void"!==t&&(d=n);else if(i){const s=e.getVarFromNode(this,null,a),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=n)}else d=`${n} = ${o}`,"void"!==t&&"void"!==u||(e.addLineFlowCode(d,this),"void"!==t&&(d=n));return l.initialized=!0,e.format(d,a,t)}}const Na=en(va).setParameterLength(2);_i("assign",Na);class Sa extends li{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)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}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)o("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(o("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");i.length<s.length;)i.push(hn(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)):(o(`TSL: Input '${e.name}' not found in 'Fn()'.`),t.push(n(hn(0),e)))}return`${r.build(e,"property")}( ${t.join(", ")} )`}}const Ra=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?Ji(t):Zi(t[0]),new Sa(Yi(e),t));_i("call",Ra);const Aa={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ea extends li{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new Ea(e,t,r);for(let t=0;t<s.length-1;t++)i=new Ea(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(Aa[this.op],t)}getNodeType(e,t=null){const r=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(e),a=i?i.getNodeType(e):null;if("void"===n||"void"===a)return t||"void";if("%"===r)return n;if("~"===r||"&"===r||"|"===r||"^"===r||">>"===r||"<<"===r)return e.getIntegerType(n);if("!"===r||"&&"===r||"||"===r||"^^"===r)return"bool";if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r){const t=Math.max(e.getTypeLength(n),e.getTypeLength(a));return t>1?`bvec${t}`:"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,{aNode:s,bNode:i}=this,n=this.getNodeType(e,t);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),l=i?i.build(e,o):null,d=e.getFunctionOperator(r);if("void"!==t){const s=e.renderer.coordinateSystem===c;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)return s&&e.isVector(a)?e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${l} )`,n,t):e.format(`( ${u} ${r} ${l} )`,n,t);if("%"===r)return e.isInteger(o)?e.format(`( ${u} % ${l} )`,n,t):e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${l} )`,n,t);if("!"===r||"~"===r)return e.format(`(${r}${u})`,a,t);if(d)return e.format(`${d}( ${u}, ${l} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${l} ${r} ${u} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${u} ${r} ${l}`,n,t);{let i=`( ${u} ${r} ${l} )`;return!s&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==a)return d?e.format(`${d}( ${u}, ${l} )`,n,t):e.isMatrix(a)&&"float"===o?e.format(`${l} ${r} ${u}`,n,t):e.format(`${u} ${r} ${l}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const wa=rn(Ea,"+").setParameterLength(2,1/0).setName("add"),Ca=rn(Ea,"-").setParameterLength(2,1/0).setName("sub"),Ma=rn(Ea,"*").setParameterLength(2,1/0).setName("mul"),Ba=rn(Ea,"/").setParameterLength(2,1/0).setName("div"),La=rn(Ea,"%").setParameterLength(2).setName("mod"),Fa=rn(Ea,"==").setParameterLength(2).setName("equal"),Pa=rn(Ea,"!=").setParameterLength(2).setName("notEqual"),Da=rn(Ea,"<").setParameterLength(2).setName("lessThan"),Ua=rn(Ea,">").setParameterLength(2).setName("greaterThan"),Ia=rn(Ea,"<=").setParameterLength(2).setName("lessThanEqual"),Oa=rn(Ea,">=").setParameterLength(2).setName("greaterThanEqual"),Va=rn(Ea,"&&").setParameterLength(2,1/0).setName("and"),ka=rn(Ea,"||").setParameterLength(2,1/0).setName("or"),Ga=rn(Ea,"!").setParameterLength(1).setName("not"),za=rn(Ea,"^^").setParameterLength(2).setName("xor"),$a=rn(Ea,"&").setParameterLength(2).setName("bitAnd"),Wa=rn(Ea,"~").setParameterLength(1).setName("bitNot"),Ha=rn(Ea,"|").setParameterLength(2).setName("bitOr"),qa=rn(Ea,"^").setParameterLength(2).setName("bitXor"),ja=rn(Ea,"<<").setParameterLength(2).setName("shiftLeft"),Xa=rn(Ea,">>").setParameterLength(2).setName("shiftRight"),Ka=an(([e])=>(e.addAssign(1),e)),Ya=an(([e])=>(e.subAssign(1),e)),Qa=an(([e])=>{const t=pn(e).toConst();return e.addAssign(1),t}),Za=an(([e])=>{const t=pn(e).toConst();return e.subAssign(1),t});_i("add",wa),_i("sub",Ca),_i("mul",Ma),_i("div",Ba),_i("mod",La),_i("equal",Fa),_i("notEqual",Pa),_i("lessThan",Da),_i("greaterThan",Ua),_i("lessThanEqual",Ia),_i("greaterThanEqual",Oa),_i("and",Va),_i("or",ka),_i("not",Ga),_i("xor",za),_i("bitAnd",$a),_i("bitNot",Wa),_i("bitOr",Ha),_i("bitXor",qa),_i("shiftLeft",ja),_i("shiftRight",Xa),_i("incrementBefore",Ka),_i("decrementBefore",Ya),_i("increment",Qa),_i("decrement",Za);const Ja=(e,t)=>(d('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),La(pn(e),pn(t)));_i("modInt",Ja);class eo extends li{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===eo.MAX||e===eo.MIN)&&arguments.length>3){let i=new eo(e,t,r);for(let t=2;t<arguments.length-1;t++)i=new eo(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===eo.LENGTH||t===eo.DISTANCE||t===eo.DOT?"float":t===eo.CROSS?"vec3":t===eo.ALL||t===eo.ANY?"bool":t===eo.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===eo.ONE_MINUS)i=Ca(1,t);else if(s===eo.RECIPROCAL)i=Ba(1,t);else if(s===eo.DIFFERENCE)i=wo(Ca(t,r));else if(s===eo.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=Sn(Tn(n),0):s=Sn(Tn(s),0);