UNPKG

three

Version:

JavaScript 3D library

6 lines 608 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,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,InterleavedBuffer as y,InterleavedBufferAttribute as b,DynamicDrawUsage as x,NoColorSpace as T,log as _,warnOnce as v,Texture as N,UnsignedIntType as S,IntType as A,NearestFilter as R,Sphere as E,BackSide as w,DoubleSide as C,Euler as M,CubeTexture as B,CubeReflectionMapping as P,CubeRefractionMapping as L,TangentSpaceNormalMap as F,ObjectSpaceNormalMap as I,InstancedInterleavedBuffer as U,InstancedBufferAttribute as D,DataArrayTexture as V,FloatType as O,FramebufferTexture as G,LinearMipmapLinearFilter as k,DepthTexture as z,Material as $,LineBasicMaterial as W,LineDashedMaterial as H,NoBlending as j,MeshNormalMaterial as q,SRGBColorSpace as X,WebGLCubeRenderTarget as K,BoxGeometry as Y,Mesh as Q,Scene as Z,LinearFilter as J,CubeCamera as ee,EquirectangularReflectionMapping as te,EquirectangularRefractionMapping as re,AddOperation as se,MixOperation as ie,MultiplyOperation as ne,MeshBasicMaterial as ae,MeshLambertMaterial as oe,MeshPhongMaterial as ue,DataTexture as le,RGFormat as de,HalfFloatType as ce,ClampToEdgeWrapping as he,BufferGeometry as pe,OrthographicCamera as ge,PerspectiveCamera as me,RenderTarget as fe,LinearSRGBColorSpace as ye,RGBAFormat as be,CubeUVReflectionMapping as xe,BufferAttribute as Te,MeshStandardMaterial as _e,MeshPhysicalMaterial as ve,MeshToonMaterial as Ne,MeshMatcapMaterial as Se,SpriteMaterial as Ae,PointsMaterial as Re,ShadowMaterial as Ee,Uint32BufferAttribute as we,Uint16BufferAttribute as Ce,arrayNeedsUint32 as Me,Camera as Be,DepthStencilFormat as Pe,DepthFormat as Le,UnsignedInt248Type as Fe,UnsignedByteType as Ie,Plane as Ue,Object3D as De,LinearMipMapLinearFilter as Ve,Float32BufferAttribute as Oe,UVMapping as Ge,VSMShadowMap as ke,LessCompare as ze,BasicShadowMap as $e,SphereGeometry as We,NormalBlending as He,LinearMipmapNearestFilter as je,NearestMipmapLinearFilter as qe,Float16BufferAttribute as Xe,REVISION as Ke,ArrayCamera as Ye,PlaneGeometry as Qe,FrontSide as Ze,CustomBlending as Je,AddEquation as et,ZeroFactor as tt,CylinderGeometry as rt,Quaternion as st,WebXRController as it,RAD2DEG as nt,PCFShadowMap as at,FrustumArray as ot,Frustum as ut,RedIntegerFormat as lt,RedFormat as dt,ShortType as ct,ByteType as ht,UnsignedShortType as pt,RGIntegerFormat as gt,RGBIntegerFormat as mt,RGBFormat as ft,RGBAIntegerFormat as yt,TimestampQuery as bt,createCanvasElement as xt,ReverseSubtractEquation as Tt,SubtractEquation as _t,OneMinusDstAlphaFactor as vt,OneMinusDstColorFactor as Nt,OneMinusSrcAlphaFactor as St,OneMinusSrcColorFactor as At,DstAlphaFactor as Rt,DstColorFactor as Et,SrcAlphaSaturateFactor as wt,SrcAlphaFactor as Ct,SrcColorFactor as Mt,OneFactor as Bt,CullFaceNone as Pt,CullFaceBack as Lt,CullFaceFront as Ft,MultiplyBlending as It,SubtractiveBlending as Ut,AdditiveBlending as Dt,NotEqualDepth as Vt,GreaterDepth as Ot,GreaterEqualDepth as Gt,EqualDepth as kt,LessEqualDepth as zt,LessDepth as $t,AlwaysDepth as Wt,NeverDepth as Ht,UnsignedShort4444Type as jt,UnsignedShort5551Type as qt,UnsignedInt5999Type as Xt,UnsignedInt101111Type as Kt,AlphaFormat as Yt,RGB_S3TC_DXT1_Format as Qt,RGBA_S3TC_DXT1_Format as Zt,RGBA_S3TC_DXT3_Format as Jt,RGBA_S3TC_DXT5_Format as er,RGB_PVRTC_4BPPV1_Format as tr,RGB_PVRTC_2BPPV1_Format as rr,RGBA_PVRTC_4BPPV1_Format as sr,RGBA_PVRTC_2BPPV1_Format as ir,RGB_ETC1_Format as nr,RGB_ETC2_Format as ar,RGBA_ETC2_EAC_Format as or,RGBA_ASTC_4x4_Format as ur,RGBA_ASTC_5x4_Format as lr,RGBA_ASTC_5x5_Format as dr,RGBA_ASTC_6x5_Format as cr,RGBA_ASTC_6x6_Format as hr,RGBA_ASTC_8x5_Format as pr,RGBA_ASTC_8x6_Format as gr,RGBA_ASTC_8x8_Format as mr,RGBA_ASTC_10x5_Format as fr,RGBA_ASTC_10x6_Format as yr,RGBA_ASTC_10x8_Format as br,RGBA_ASTC_10x10_Format as xr,RGBA_ASTC_12x10_Format as Tr,RGBA_ASTC_12x12_Format as _r,RGBA_BPTC_Format as vr,RED_RGTC1_Format as Nr,SIGNED_RED_RGTC1_Format as Sr,RED_GREEN_RGTC2_Format as Ar,SIGNED_RED_GREEN_RGTC2_Format as Rr,MirroredRepeatWrapping as Er,RepeatWrapping as wr,NearestMipmapNearestFilter as Cr,NotEqualCompare as Mr,GreaterCompare as Br,GreaterEqualCompare as Pr,EqualCompare as Lr,LessEqualCompare as Fr,AlwaysCompare as Ir,NeverCompare as Ur,LinearTransfer as Dr,getByteLength as Vr,NotEqualStencilFunc as Or,GreaterStencilFunc as Gr,GreaterEqualStencilFunc as kr,EqualStencilFunc as zr,LessEqualStencilFunc as $r,LessStencilFunc as Wr,AlwaysStencilFunc as Hr,NeverStencilFunc as jr,DecrementWrapStencilOp as qr,IncrementWrapStencilOp as Xr,DecrementStencilOp as Kr,IncrementStencilOp as Yr,InvertStencilOp as Qr,ReplaceStencilOp as Zr,ZeroStencilOp as Jr,KeepStencilOp as es,MaxEquation as ts,MinEquation as rs,SpotLight as ss,PointLight as is,DirectionalLight as ns,RectAreaLight as as,AmbientLight as os,HemisphereLight as us,LightProbe as ls,LinearToneMapping as ds,ReinhardToneMapping as cs,CineonToneMapping as hs,ACESFilmicToneMapping as ps,AgXToneMapping as gs,NeutralToneMapping as ms,Group as fs,Loader as ys,FileLoader as bs,MaterialLoader as xs,ObjectLoader as Ts}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 _s=["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"],vs=new WeakMap;class Ns{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=_s,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){const t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){const{geometry:r,material:s,object:i}=e;if(t={material:this.getMaterialData(s),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){const{width:r,height:s}=e.context;t.bufferWidth=r,t.bufferHeight=s}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];null!=s&&("object"==typeof s&&void 0!==s.clone?!0===s.isTexture?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e,t){const{object:r,material:s,geometry:i}=e,n=this.getRenderObjectData(e);if(!0!==n.worldMatrix.equals(r.matrixWorld))return n.worldMatrix.copy(r.matrixWorld),!1;const a=n.material;for(const e in a){const t=a[e],r=s[e];if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){const{width:t,height:r}=e.context;if(n.bufferWidth!==t||n.bufferHeight!==r)return n.bufferWidth=t,n.bufferHeight=r,!1}const o=n.geometry,u=i.attributes,l=o.attributes,d=Object.keys(l),c=Object.keys(u);if(o.id!==i.id)return o.id=i.id,!1;if(d.length!==c.length)return n.geometry.attributes=this.getAttributesData(u),!1;for(const e of d){const t=l[e],r=u[e];if(void 0===r)return delete l[e],!1;if(t.version!==r.version)return t.version=r.version,!1}const h=i.index,p=o.indexVersion,g=h?h.version:null;if(p!==g)return o.indexVersion=g,!1;if(o.drawRange.start!==i.drawRange.start||o.drawRange.count!==i.drawRange.count)return o.drawRange.start=i.drawRange.start,o.drawRange.count=i.drawRange.count,!1;if(n.morphTargetInfluences){let e=!1;for(let t=0;t<n.morphTargetInfluences.length;t++)n.morphTargetInfluences[t]!==r.morphTargetInfluences[t]&&(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(vs.has(e)){const r=vs.get(e);if(r.renderId===t)return r.lightsData}const r=this.getLightsData(e.getLights());return vs.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 Ss(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 As=e=>Ss(e),Rs=e=>Ss(e),Es=(...e)=>Ss(e),ws=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Cs=new WeakMap;function Ms(e){return ws.get(e)}function Bs(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 Ps(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 Ls(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 Fs(e){return/float|int|uint/.test(e)?4:/vec2/.test(e)?8:/vec3/.test(e)||/vec4/.test(e)?16:/mat2/.test(e)?8:/mat3/.test(e)?48:/mat4/.test(e)?64:void o("TSL: Unsupported type:",e)}function Is(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 Us(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?Os(u[0]):null}function Ds(e){let t=Cs.get(e);return void 0===t&&(t={},Cs.set(e,t)),t}function Vs(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 Os(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var Gs=Object.freeze({__proto__:null,arrayBufferToBase64:Vs,base64ToArrayBuffer:Os,getByteBoundaryFromType:Fs,getDataFromObject:Ds,getLengthFromType:Ps,getMemoryLengthFromType:Ls,getTypeFromLength:Ms,getTypedArrayFromType:Bs,getValueFromType:Us,getValueType:Is,hash:Es,hashArray:Rs,hashString:As});const ks={VERTEX:"vertex",FRAGMENT:"fragment"},zs={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},$s={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Ws={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Hs=["fragment","vertex"],js=["setup","analyze","generate"],qs=[...Hs,"compute"],Xs=["x","y","z","w"],Ks={analyze:"setup",generate:"analyze"};let Ys=0;class Qs extends u{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=zs.NONE,this.updateBeforeType=zs.NONE,this.updateAfterType=zs.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:Ys++})}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,zs.FRAME)}onRenderUpdate(e){return this.onUpdate(e,zs.RENDER)}onObjectUpdate(e){return this.onUpdate(e,zs.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(As(s.slice(0,-4)),i.getCacheKey(e,t));this._cacheKey=Es(Rs(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=Ks[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 Zs extends Qs{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 Js extends Qs{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 ei extends Qs{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 ti extends ei{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 ri=Xs.join("");class si extends Qs{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(Xs.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===ri.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 ii extends ei{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=Xs[e];t===r[0]?(d.push(o),e+=r.length-1):d.push(u+"."+t)}return`${e.getType(i)}( ${d.join(", ")} )`}}class ni extends ei{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=Xs[e];r===t[l]?(u.push("1.0 - "+a+"."+r),l++):u.push(a+"."+r)}return`${e.getType(s)}( ${u.join(", ")} )`}}class ai extends Qs{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?Is(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=Is(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=Vs(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Us(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 oi=/float|u?int/;class ui extends ai{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 oi.test(r)&&oi.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class li extends Qs{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 di=null;const ci=new Map;function hi(e,t){if(ci.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`);ci.set(e,t),"assign"!==e&&(Qs.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},Qs.prototype[e+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}}const pi=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("");Qs.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==di?di.assign(this,...e):o("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const t=ci.get("assign");return this.addToStack(t(...e))}},Qs.prototype.toVarIntent=function(){return this},Qs.prototype.get=function(e){return new li(this,e)};const gi={};function mi(e,t,r){gi[e]=gi[t]=gi[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new si(this,e),this._cache[e]=t),t},set(t){this[e].assign(ki(t))}};const s=e.toUpperCase(),i=t.toUpperCase(),n=r.toUpperCase();Qs.prototype["set"+s]=Qs.prototype["set"+i]=Qs.prototype["set"+n]=function(t){const r=pi(e);return new ii(this,r,ki(t))},Qs.prototype["flip"+s]=Qs.prototype["flip"+i]=Qs.prototype["flip"+n]=function(){const t=pi(e);return new ni(this,t)}}const fi=["x","y","z","w"],yi=["r","g","b","a"],bi=["s","t","p","q"];for(let e=0;e<4;e++){let t=fi[e],r=yi[e],s=bi[e];mi(t,r,s);for(let i=0;i<4;i++){t=fi[e]+fi[i],r=yi[e]+yi[i],s=bi[e]+bi[i],mi(t,r,s);for(let n=0;n<4;n++){t=fi[e]+fi[i]+fi[n],r=yi[e]+yi[i]+yi[n],s=bi[e]+bi[i]+bi[n],mi(t,r,s);for(let a=0;a<4;a++)t=fi[e]+fi[i]+fi[n]+fi[a],r=yi[e]+yi[i]+yi[n]+yi[a],s=bi[e]+bi[i]+bi[n]+bi[a],mi(t,r,s)}}}for(let e=0;e<32;e++)gi[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new Zs(this,new ui(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(ki(t))}};Object.defineProperties(Qs.prototype,gi);const xi=new WeakMap,Ti=function(e,t=null){for(const r in e)e[r]=ki(e[r],t);return e},_i=function(e,t=null){const r=e.length;for(let s=0;s<r;s++)e[s]=ki(e[s],t);return e},vi=function(e,t=null,r=null,s=null){function i(e){return null!==s?(e=ki(Object.assign(e,s)),!0===s.intent&&(e=e.toVarIntent())):e=ki(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(...Wi(d(t)))):null!==r?(r=ki(r),n=(...s)=>i(new e(t,...Wi(d(s)),r))):n=(...r)=>i(new e(t,...Wi(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},Ni=function(e,...t){return ki(new e(...Wi(t)))};class Si extends Qs{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=xi.get(e.constructor);void 0===s&&(s=new WeakMap,xi.set(e.constructor,s));let i=s.get(t);void 0===i&&(i=ki(e.buildFunctionNode(t)),s.set(t,i)),e.addInclude(i);const n=r?function(e){let t;$i(e);t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];return t}(r):null;u=ki(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 $i(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 ki(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 Qs&&(n=void 0===e[s]?e[t++]:Reflect.get(e,s,i));else n=Reflect.get(r,s,i);n=ki(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=ki(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 Ai extends Qs{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 Si(this,e)}setup(){return this.call()}}const Ri=[!1,!0],Ei=[0,1,2,3],wi=[-1,-2],Ci=[.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],Mi=new Map;for(const e of Ri)Mi.set(e,new ui(e));const Bi=new Map;for(const e of Ei)Bi.set(e,new ui(e,"uint"));const Pi=new Map([...Bi].map(e=>new ui(e.value,"int")));for(const e of wi)Pi.set(e,new ui(e,"int"));const Li=new Map([...Pi].map(e=>new ui(e.value)));for(const e of Ci)Li.set(e,new ui(e));for(const e of Ci)Li.set(-e,new ui(-e));const Fi={bool:Mi,uint:Bi,ints:Pi,float:Li},Ii=new Map([...Mi,...Li]),Ui=(e,t)=>Ii.has(e)?Ii.get(e):!0===e.isNode?e:new ui(e,t),Di=function(e,t=null){return(...r)=>{for(const t of r)if(void 0===t)return o(`TSL: Invalid parameter for the type "${e}".`),ki(new ui(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=[Us(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return zi(t.get(r[0]));if(1===r.length){const t=Ui(r[0],e);return t.nodeType===e?zi(t):zi(new Js(t,e))}const s=r.map(e=>Ui(e));return zi(new ti(s,e))}},Vi=e=>"object"==typeof e&&null!==e?e.value:e,Oi=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Gi(e,t){return new Ai(e,t)}const ki=(e,t=null)=>function(e,t=null){const r=Is(e);return"node"===r?e:null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?ki(Ui(e,t)):"shader"===r?e.isFn?e:Yi(e):e}(e,t),zi=(e,t=null)=>ki(e,t).toVarIntent(),$i=(e,t=null)=>new Ti(e,t),Wi=(e,t=null)=>new _i(e,t),Hi=(e,t=null,r=null,s=null)=>new vi(e,t,r,s),ji=(e,...t)=>new Ni(e,...t),qi=(e,t=null,r=null,s={})=>new vi(e,t,r,{...s,intent:!0});let Xi=0;class Ki extends Qs{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 Gi(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"+Xi++,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 Yi(e,t=null){const r=new Ki(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 Qi=e=>{di=e},Zi=()=>di,Ji=(...e)=>di.If(...e);function en(e){return di&&di.addToStack(e),e}hi("toStack",en);const tn=new Di("color"),rn=new Di("float",Fi.float),sn=new Di("int",Fi.ints),nn=new Di("uint",Fi.uint),an=new Di("bool",Fi.bool),on=new Di("vec2"),un=new Di("ivec2"),ln=new Di("uvec2"),dn=new Di("bvec2"),cn=new Di("vec3"),hn=new Di("ivec3"),pn=new Di("uvec3"),gn=new Di("bvec3"),mn=new Di("vec4"),fn=new Di("ivec4"),yn=new Di("uvec4"),bn=new Di("bvec4"),xn=new Di("mat2"),Tn=new Di("mat3"),_n=new Di("mat4");hi("toColor",tn),hi("toFloat",rn),hi("toInt",sn),hi("toUint",nn),hi("toBool",an),hi("toVec2",on),hi("toIVec2",un),hi("toUVec2",ln),hi("toBVec2",dn),hi("toVec3",cn),hi("toIVec3",hn),hi("toUVec3",pn),hi("toBVec3",gn),hi("toVec4",mn),hi("toIVec4",fn),hi("toUVec4",yn),hi("toBVec4",bn),hi("toMat2",xn),hi("toMat3",Tn),hi("toMat4",_n);const vn=Hi(Zs).setParameterLength(2),Nn=(e,t)=>ki(new Js(ki(e),t));hi("element",vn),hi("convert",Nn);hi("append",e=>(d("TSL: .append() has been renamed to .toStack()."),en(e)));class Sn extends Qs{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 As(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 An=(e,t)=>ki(new Sn(e,t)),Rn=(e,t)=>ki(new Sn(e,t,!0)),En=ji(Sn,"vec4","DiffuseColor"),wn=ji(Sn,"vec3","EmissiveColor"),Cn=ji(Sn,"float","Roughness"),Mn=ji(Sn,"float","Metalness"),Bn=ji(Sn,"float","Clearcoat"),Pn=ji(Sn,"float","ClearcoatRoughness"),Ln=ji(Sn,"vec3","Sheen"),Fn=ji(Sn,"float","SheenRoughness"),In=ji(Sn,"float","Iridescence"),Un=ji(Sn,"float","IridescenceIOR"),Dn=ji(Sn,"float","IridescenceThickness"),Vn=ji(Sn,"float","AlphaT"),On=ji(Sn,"float","Anisotropy"),Gn=ji(Sn,"vec3","AnisotropyT"),kn=ji(Sn,"vec3","AnisotropyB"),zn=ji(Sn,"color","SpecularColor"),$n=ji(Sn,"float","SpecularF90"),Wn=ji(Sn,"float","Shininess"),Hn=ji(Sn,"vec4","Output"),jn=ji(Sn,"float","dashSize"),qn=ji(Sn,"float","gapSize"),Xn=ji(Sn,"float","pointWidth"),Kn=ji(Sn,"float","IOR"),Yn=ji(Sn,"float","Transmission"),Qn=ji(Sn,"float","Thickness"),Zn=ji(Sn,"float","AttenuationDistance"),Jn=ji(Sn,"color","AttenuationColor"),ea=ji(Sn,"float","Dispersion");class ta extends Qs{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 ra=e=>new ta(e),sa=(e,t=0)=>new ta(e,!0,t),ia=sa("frame"),na=sa("render"),aa=ra("object");class oa extends ai{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=aa}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 ua=(e,t)=>{const r=Oi(t||e);return r===e&&(e=Us(r)),e=e&&!0===e.isNode?e.node&&e.node.value||e.value:e,ki(new oa(e,r))};class la extends ei{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return null===this.nodeType&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const da=(...e)=>{let t;if(1===e.length){const r=e[0];t=new la(null,r.length,r)}else{const r=e[0],s=e[1];t=new la(r,s)}return ki(t)};hi("toArray",(e,t)=>da(Array(t).fill(e)));class ca extends ei{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 Xs.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=t.getScope();e.getNodeProperties(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 ha=Hi(ca).setParameterLength(2);hi("assign",ha);class pa extends ei{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(rn(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(rn(0),e)))}return`${r.build(e,"property")}( ${t.join(", ")} )`}}const ga=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?Wi(t):$i(t[0]),new pa(ki(e),t));hi("call",ga);const ma={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class fa extends ei{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let i=new fa(e,t,r);for(let t=0;t<s.length-1;t++)i=new fa(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(ma[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 ya=qi(fa,"+").setParameterLength(2,1/0).setName("add"),ba=qi(fa,"-").setParameterLength(2,1/0).setName("sub"),xa=qi(fa,"*").setParameterLength(2,1/0).setName("mul"),Ta=qi(fa,"/").setParameterLength(2,1/0).setName("div"),_a=qi(fa,"%").setParameterLength(2).setName("mod"),va=qi(fa,"==").setParameterLength(2).setName("equal"),Na=qi(fa,"!=").setParameterLength(2).setName("notEqual"),Sa=qi(fa,"<").setParameterLength(2).setName("lessThan"),Aa=qi(fa,">").setParameterLength(2).setName("greaterThan"),Ra=qi(fa,"<=").setParameterLength(2).setName("lessThanEqual"),Ea=qi(fa,">=").setParameterLength(2).setName("greaterThanEqual"),wa=qi(fa,"&&").setParameterLength(2,1/0).setName("and"),Ca=qi(fa,"||").setParameterLength(2,1/0).setName("or"),Ma=qi(fa,"!").setParameterLength(1).setName("not"),Ba=qi(fa,"^^").setParameterLength(2).setName("xor"),Pa=qi(fa,"&").setParameterLength(2).setName("bitAnd"),La=qi(fa,"~").setParameterLength(1).setName("bitNot"),Fa=qi(fa,"|").setParameterLength(2).setName("bitOr"),Ia=qi(fa,"^").setParameterLength(2).setName("bitXor"),Ua=qi(fa,"<<").setParameterLength(2).setName("shiftLeft"),Da=qi(fa,">>").setParameterLength(2).setName("shiftRight"),Va=Yi(([e])=>(e.addAssign(1),e)),Oa=Yi(([e])=>(e.subAssign(1),e)),Ga=Yi(([e])=>{const t=sn(e).toConst();return e.addAssign(1),t}),ka=Yi(([e])=>{const t=sn(e).toConst();return e.subAssign(1),t});hi("add",ya),hi("sub",ba),hi("mul",xa),hi("div",Ta),hi("mod",_a),hi("equal",va),hi("notEqual",Na),hi("lessThan",Sa),hi("greaterThan",Aa),hi("lessThanEqual",Ra),hi("greaterThanEqual",Ea),hi("and",wa),hi("or",Ca),hi("not",Ma),hi("xor",Ba),hi("bitAnd",Pa),hi("bitNot",La),hi("bitOr",Fa),hi("bitXor",Ia),hi("shiftLeft",Ua),hi("shiftRight",Da),hi("incrementBefore",Va),hi("decrementBefore",Oa),hi("increment",Ga),hi("decrement",ka);const za=(e,t)=>(d('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),_a(sn(e),sn(t)));hi("modInt",za);class $a extends ei{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===$a.MAX||e===$a.MIN)&&arguments.length>3){let i=new $a(e,t,r);for(let t=2;t<arguments.length-1;t++)i=new $a(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===$a.LENGTH||t===$a.DISTANCE||t===$a.DOT?"float":t===$a.CROSS?"vec3":t===$a.ALL||t===$a.ANY?"bool":t===$a.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===$a.ONE_MINUS)i=ba(1,t);else if(s===$a.RECIPROCAL)i=Ta(1,t);else if(s===$a.DIFFERENCE)i=yo(ba(t,r));else if(s===$a.TRANSFORM_DIRECTION){let s=t,n=r;e.isMatrix(s.getNodeType(e))?n=mn(cn(n),0):s=mn(cn(s),0);const a=xa(s,n).xyz;i=uo(a)}return null!==i?i:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const s=this.getNodeType(e),i=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,u=e.renderer.coordinateSystem;if(r===$a.NEGATE)return e.format("( - "+n.build(e,i)+" )",s,t);{const l=[];return r===$a.CROSS?l.push(n.build(e,s),a.build(e,s)):u===c&&r===$a.STEP?l.push(n.bu